-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeGoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.modules
Milestone
Description
What version of Go are you using (go version
)?
> go version [stdout] go version go1.12beta1 linux/amd64
Does this issue reproduce with the latest release?
Yes; testing with the beta ahead of the 1.12 release.
What operating system and processor architecture are you using (go env
)?
go env
Output
> go env [stdout] GOARCH="amd64" GOBIN="" GOCACHE="/home/myitcv/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="$WORK/gopath" GOPROXY="http://127.0.0.1:40043/mod" GORACE="" GOROOT="/home/myitcv/gos" GOTMPDIR="" GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="$WORK/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK/tmp/go-build168896432=/tmp/go-build -gno-record-gcc-switches"
What did you do?
# no build constraint
go list
go mod tidy
grep 'fruit.com v1.0.0' go.mod
# build constraint of other
cp mod.go.other mod.go
go mod tidy
grep 'fruit.com v1.0.0' go.mod
# build constraint of ignore
cp mod.go.ignore mod.go
go mod tidy
grep 'fruit.com v1.0.0' go.mod
-- go.mod --
module mod
-- mod.go --
package mod
import _ "fruit.com/fruit"
-- mod.go.ignore --
// +build ignore
package mod
import _ "fruit.com/fruit"
-- mod.go.other --
// +build other
package mod
import _ "fruit.com/fruit"
using the following module definition:
# mod/fruit.com_v1.0.0.txt
-- .mod --
module fruit.com
-- .info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- go.mod --
module fruit.com
-- fruit/fruit.go --
package fruit
What did you expect to see?
A passing test.
What did you see instead?
--- FAIL: TestScripts (0.04s)
--- FAIL: TestScripts/script (0.23s)
testscript.go:193:
# no build constraint (0.107s)
# build constraint of other (0.021s)
# build constraint of ignore (0.032s)
> cp mod.go.ignore mod.go
> go mod tidy
> grep 'fruit.com v1.0.0' go.mod
[go.mod]
module mod
go 1.12
FAIL: testdata/script.txt:17: no match for `fruit.com v1.0.0` found in go.mod
I wasn't aware that the ignore
build constraint was special but judging from the above it appears to be.
ignore
is described as being conventional, but not that it carries any special semantics.
The cmd/go
docs also don't appear to make mention of this special case.
Assuming this is the intended behaviour, I think it would be worth updating the docs to call this out. I just spent a good few mins trying to track down a go mod tidy
bug that in fact turned out to be an instance of a file with a // +build ignore
constraint.
cc @bcmills
mvdan, dmitshur, tmthrgd, haowjern, segevfiner and 3 more
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeGoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.modules