Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.15 linux/amd64
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE=""
What did you do?
Run go get go.felesatra.moe/animanager
outside of module dir.
What did you expect to see?
Success
What did you see instead?
package go.felesatra.moe/animanager: unrecognized import path "go.felesatra.moe/animanager": parse https://go.felesatra.moe/animanager?go-get=1: no go-import meta tags ()
Note that go.felesatra.moe/animanager
does include a go-import meta tag, but using mod instead of a vcs value.
It's arguable whether this is a bug. Strictly speaking, go get
is behaving as documented:
For more fine-grained control, the go command continues to respect
a temporary environment variable, GO111MODULE, which can be set to one
of three string values: off, on, or auto (the default).
If GO111MODULE=on, then the go command requires the use of modules,
never consulting GOPATH. We refer to this as the command
being module-aware or running in "module-aware mode".
If GO111MODULE=off, then the go command never uses
module support. Instead it looks in vendor directories and GOPATH
to find dependencies; we now refer to this as "GOPATH mode."
If GO111MODULE=auto or is unset, then the go command enables or disables
module support based on the current directory.
Module support is enabled only when the current directory contains a
go.mod file or is below a directory containing a go.mod file.
So running go get
outside of a module dir has module support disabled, so it does not support mod meta tags.
However, practically speaking it's not desirable that you can't go get
a program if it uses a mod meta tag, since end users don't care about that (it works if you explicitly set GO111MODULE=on
, naturally).