cmd/go: 'go test' and 'go vet' require GCC even when 'go build' does not #56755
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This is tested inside an Ubuntu 22.04 lxd container, started from
images:ubuntu/22.04/cloud
. This provides the "ubuntu-minimal" distribution, which doesn't have gcc / build-essential packages installed by default.Then in this directory:
What did you expect to see?
All these commands to succeed.
What did you see instead?
go build .
succeeds, butgo test .
andgo vet .
fail.Additional info
I have found that:
go test -vet=off .
worksnet/http
, thengo test .
works.net/http
tonet/netip
, thengo test .
worksnet/http
tonet
, thengo test .
still failsgo mod tidy
makes no differenceTherefore this appears to be something to do with importing specific net libraries in the presence of
go vet
I expect most people don't notice this because most developers do have gcc installed.
Workaround
or:
I don't like the first option, because it makes me worry that the artefact from
go build
is different to the one being tested. I guess I could also useCGO_ENABLED=0 go build .
to ensure the build product is consistent.I don't like the second one because I lose the vet checks.
But splitting vet and test looks to be a reasonable solution:
Linked / related issues
Forked from #28065 on request. See also #27639, #27303.
This new issue removes any ambiguity around Alpine Linux / musl libc or GOPATH mode; neither is relevant.
The text was updated successfully, but these errors were encountered: