-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Thinkingmodules
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.18.5 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/mlaventure/.cache/go-build" GOENV="/home/mlaventure/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/mlaventure/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/mlaventure/go" GOPRIVATE="" GOPROXY="direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18.5" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/mlaventure/tmp/go/workspace/realdeal/go.mod" GOWORK="/home/mlaventure/tmp/go/workspace/go.work" 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=/tmp/go-build2178506260=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Given the following workspace structure:
~/tmp/go/workspace $ tree
.
├── fubar
│ ├── fubar.go
│ └── go.mod
├── go.work
└── realdeal
├── go.mod
├── realdeal
└── realdeal.go
2 directories, 6 files
With the following go.work
:
~/tmp/go/workspace $ cat go.work
go 1.18
use ./fubar
use ./realdeal
replace github.com/foo/fubar => ./fubar
Build realdeal
which depends on fubar
:
~/tmp/go/workspace/realdeal $ go build .
What did you expect to see?
Nothing, the build should succeed
What did you see instead?
go: workspace module github.com/foo/fubar is replaced at all versions in the go.work file. To fix, remove the replacement from the go.work file or specify the version at which to replace the module.
Found workaround
The only way I've found to fix this is to update the go.work
to be as follow:
~/tmp/go/workspace $ cat go.work
go 1.18
use ./fubar
use ./realdeal
replace github.com/foo/fubar v0.0.0-00010101000000-000000000000 => ./fubar
This is not needed if a workspace is not used. It also seems to contradict the example from the documentation (https://go.dev/ref/mod#workspaces):
replace (
golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5
golang.org/x/net => example.com/fork/net v1.4.5
golang.org/x/net v1.2.3 => ./fork/net
golang.org/x/net => ./fork/net
)
rootulp, mksmsrgnk, CTrando, tserkov, Mikulas and 53 moreJonathanHuotfolays
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Thinkingmodules