Closed as not planned
Closed as not planned
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/fubar/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-build500860194=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Given a monorepo setup as follow:
~/tmp/go $ tree
.
├── foo
│ ├── foo.go
│ └── go.mod
└── workspace
├── fubar
│ ├── go.mod
│ └── main.go
└── go.work
3 directories, 5 files
With the following go.work
:
go 1.18
use ./fubar
replace github.com/foo/foo => ../foo
When getting the list of replaced modules, the .Replace.Path
entry is given relative to the go.work
file instead of relative to the current folder the command was invoked from. The command ran was the following:
~/tmp/go/workspace/fubar$ go list -json -m all
What did you expect to see?
Path
being appropriately set to reflect the current directory
{
"Path": "github.com/foo/foo",
"Version": "v0.0.0-00010101000000-000000000000",
"Replace": {
"Path": "../../foo",
"Dir": "/home/mlaventure/tmp/go/foo",
"GoMod": "/home/mlaventure/tmp/go/foo/go.mod",
"GoVersion": "1.18"
},
"Indirect": true,
"Dir": "/home/mlaventure/tmp/go/foo",
"GoMod": "/home/mlaventure/tmp/go/foo/go.mod",
"GoVersion": "1.18"
}
What did you see instead?
{
"Path": "github.com/foo/foo",
"Version": "v0.0.0-00010101000000-000000000000",
"Replace": {
"Path": "../foo",
"Dir": "/home/mlaventure/tmp/go/foo",
"GoMod": "/home/mlaventure/tmp/go/foo/go.mod",
"GoVersion": "1.18"
},
"Indirect": true,
"Dir": "/home/mlaventure/tmp/go/foo",
"GoMod": "/home/mlaventure/tmp/go/foo/go.mod",
"GoVersion": "1.18"
}