Skip to content
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: resolve local paths to modules in subdirectory replacements #43733

Open
jayconrod opened this issue Jan 15, 2021 · 0 comments
Open

cmd/go: resolve local paths to modules in subdirectory replacements #43733

jayconrod opened this issue Jan 15, 2021 · 0 comments
Labels
Milestone

Comments

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Jan 15, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16beta1 darwin/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="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jayconrod/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16beta1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayconrod/Code/test3/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build3849412287=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run go list or any other module-aware command on an absolute or relative path (starting with ./) that points to a subdirectory inside a separate module which provides a replacement.

go list ./sub
go list $(pwd)/sub

-- go.mod --
module example.com/m

go 1.16

require example.com/m/sub v0.0.0

replace example.com/m/sub v0.0.0 => ./sub
-- sub/go.mod --
module example.com/m/sub

go 1.16
-- sub/sub.go --
package sub

What did you expect to see?

go list should succeed and print the package path. In the example above, it should print example.com/m/sub.

What did you see instead?

go list fails with:

main module (example.com/m) does not contain package example.com/m/sub

It looks like the go command resolves the path argument to a directory within the module before checking whether it might be part of a replacement module in another directory.

Other notes

This issue is related to the thread go list across multiple modules on golang-nuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants