New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: add a way to support GOFLAGS=-ldflags='-w -s' #29096

mvdan opened this Issue Dec 4, 2018 · 3 comments


None yet
3 participants

mvdan commented Dec 4, 2018

The previous documentation example mentioned GOFLAGS='-ldflags=-w -ldflags=-s', which does something completely different. The second per-package flag overrides the first, so the linker ends up being called with just -s and not -w -s.

There should be a way to do go build -ldflags='-w -s' via GOFLAGS. This can either be done by tweaking GOFLAGS, or by tweaking per-package flags - I personally don't mind, as long as there's a way to achieve it.

/cc @bcmills @rsc

@mvdan mvdan added the NeedsFix label Dec 4, 2018


This comment has been minimized.

gopherbot commented Dec 4, 2018

Change mentions this issue: cmd/go: revert multi-flag GOFLAGS doc example


This comment has been minimized.


bcmills commented Dec 4, 2018

#26849 is one possible mechanism.

gopherbot pushed a commit that referenced this issue Dec 4, 2018

cmd/go: revert multi-flag GOFLAGS doc example
This partially reverts

Reason for revert: multiple -ldflags=-foo flags simply override each
other, since that's the logic for per-package flags. The suggested
'GOFLAGS=-ldflags=-s -ldflags=-w' has never worked for 'go build', and
even breaks 'go test' and 'go vet'.

There should be a way to specify -ldflags='-w -s' via GOFLAGS, which is
being tracked in #29096. For now, just remove the incorrect suggestion.

Fixes #29053.

Change-Id: I9203056f7e5191e894bcd16595a92df2fb704ea7
Reviewed-by: Bryan C. Mills <>
Reviewed-by: Alan Donovan <>
Run-TryBot: Daniel Martí <>

@mvdan mvdan added this to the Go1.13 milestone Dec 15, 2018


This comment has been minimized.


mvdan commented Dec 15, 2018

Go 1.11 supposedly shipped with this feature, so I'm milestoning this for 1.13 to "get that back". Within quotes because it never actually worked :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment