You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cd $(mktemp -d)
mkdir -p src/example.com/p
echo 'package p' >src/example.com/p/p.go
export GO111MODULE=on
export GOPATH=$(pwd)
go doc example.com/p
What did you expect to see?
go doc example.com/p should fail. Module mode is turned on explicitly with GO111MODULE=on, and that package only exists in this fake GOPATH.
What did you see instead?
go doc example.com/p succeeds with the output below:
warning: pattern "all" matched no module dependencies
Analysis
go doc executes cmd/doc, which loads a package with go/build.Import. There is a heuristic which guesses whether module mode is enabled by looking for a go.mod file. If one is found, it loads the package by executing go list.
The heuristic should assume modules are enabled when GO111MODULE is explicitly on.
The text was updated successfully, but these errors were encountered:
Change https://golang.org/cl/198778 mentions this issue: cmd/go: forbid resolving import to modules when outside of a module
jayconrod
changed the title
go/build: resolved package in GOPATH when GO111MODULE=on outside module
go/build: resolve package in GOPATH when GO111MODULE=on outside module
Oct 8, 2019
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?
What did you expect to see?
go doc example.com/p
should fail. Module mode is turned on explicitly withGO111MODULE=on
, and that package only exists in this fake GOPATH.What did you see instead?
go doc example.com/p
succeeds with the output below:Analysis
go doc
executescmd/doc
, which loads a package withgo/build.Import
. There is a heuristic which guesses whether module mode is enabled by looking for a go.mod file. If one is found, it loads the package by executinggo list
.The heuristic should assume modules are enabled when
GO111MODULE
is explicitlyon
.The text was updated successfully, but these errors were encountered: