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: go get <module> is not restricted to desired module #47195

Closed
andig opened this issue Jul 14, 2021 · 2 comments
Closed

cmd/go: go get <module> is not restricted to desired module #47195

andig opened this issue Jul 14, 2021 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@andig
Copy link
Contributor

andig commented Jul 14, 2021

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

$ go version
go version go1.16.5 darwin/arm64

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
❯ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.16.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.16.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build187128154=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Update module using go get

What did you expect to see?

go.mod updated, no error.

What did you see instead?

Error on unrelated module:

❯ go get github.com/bogosj/tesla
go: gitlab.com/bboehmke/sunny@v0.14.2: Get "https://proxy.golang.org/gitlab.com/bboehmke/sunny/@v/v0.14.2.mod": dial tcp 142.251.36.241:443: i/o timeout

❯ GOPROXY=off go get -d github.com/bogosj/tesla
go: gitlab.com/bboehmke/sunny@v0.14.2: module lookup disabled by GOPROXY=off

While the error is transient, it is not clear why updating a single module should regard all others. It should be possible to update a single module even if others fail to resolve.

@cherrymui cherrymui changed the title go get <module> is not restricted to desired module cmd/go: go get <module> is not restricted to desired module Jul 14, 2021
@cherrymui
Copy link
Member

cc @bcmills @jayconrod @matloob

@cherrymui cherrymui added this to the Backlog milestone Jul 14, 2021
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 14, 2021
@jayconrod
Copy link
Contributor

Sorry, it's not feasible to fix this without making a major change to the semantics of go get.

go get, like other module-aware commands, loads the build list (set of selected module versions) when it starts. That requires loading the go.mod file for each dependency, which may require fetching those files if they aren't in the module cache.

go get can't work without the build list because upgrading (or adding or downgrading or removing) a dependency can affect other dependencies. For example, suppose A 1.1 depends on B 1.5, but A 1.2 does not depend on B. If you upgrade to A 1.2, you could unintentionally downgrade or remove B. go get prevents that from happening by adding an explicit // indirect requirement.

Also perhaps more importantly, go get may operate on either packages or modules. When an argument refers to a package, go get loads all the transitively imported packages, and the build list is certainly required for that.

@golang golang locked and limited conversation to collaborators Jul 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants