Skip to content

os/exec: pass more than 1 ldflags #33581

@pjebs

Description

@pjebs

I'm using Go 1.10 in windows:

For some reason it appears as if -ldflags doesn't allow combining flags when used with exec.CommandContext.

cmd = exec.CommandContext(ctx, "go", "build", "-o", outputPath, "-ldflags=-s", "-ldflags=-w", "-ldflags \"-H windowsgui\"", goFilePath)
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", "GOOS", "windows"))

cmd.CombinedOutput()

The later ldflag flag seems to overwrite the prior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions