Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: module go install cmd with relative import path resolved against $GOPATH #35918
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
I think this is working as intended.
Relative paths are described in
Well...that is curious. The package did have a go.mod file, and it was ignored. The entire go install process ignored the go.mod files -- but simply changing the install command to be inside the directory triggered module=on behavior. So two different forms of the "go install" command cause different results: one ignores the go.mod files and does a local disk compile and the other recognizes the modules and goes out to github.com to resolve the imports, etc.
And look at "go help gopath":
"GOPATH and Modules
When using modules, GOPATH is no longer used for resolving imports.
So if Go had been using modules it would have ignored the gopath/src and gone out to github to get the imports. I have tested this and that is the way it works.
If you think it works as intended, then that is fine with me. It just doesn't seem to match the documentation.
From "go help packages"
An import path that is a rooted path or that begins with a . or .. element is interpreted as a file system path and denotes the package in that directory.
Otherwise, the import path P denotes the package found in the directory DIR/src/P for some DIR listed in the GOPATH environment variable (For more details see: 'go help gopath').
I think that is pretty clear: it "denotes the package found in that directory". And in my case, that package had a go.mod file. Which was ignored. To take the alternative reading of the documentation would be to say: 'Fire up the command line and enter "go install github.com/userid/repo/pkgname" and if the user's home directory has a go.mod file that is what will be input to go install.' Would that be reasonable behavior?
Go 1.13 includes support for Go modules. Module-aware mode is active by default whenever a go.mod file is found in, or in a parent of, the current directory.