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' of non-main packages outside of a module is confusing in module mode #47290

Closed
bcmills opened this issue Jul 19, 2021 · 4 comments
Labels
FrozenDueToAge GoCommand cmd/go help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jul 19, 2021

In module mode today, go get on a non-main package downloads that package to the module cache, builds that package (until we finish #43684), and leaves it in the build cache.

This behavior can be confusing for users who are working from older, GOPATH-based materials (as in https://stackoverflow.com/q/68420141). In GOPATH mode this would have cloned the package's source repo to GOPATH/src, but in module mode it instead downloads the module containing the source to a versioned path within GOPATH/pkg/mod.

If go get is invoked on a non-main package in module mode outside of any module, we should probably at least log a message indicating where the source code is now found.

/tmp$ go1.17beta1 env GOMOD
/dev/null

/tmp$ go1.17beta1 get golang.org/x/net/html

/tmp$ find $(go1.17beta1 env GOPATH)/src -type f

/tmp$ go clean -modcache

/tmp$ go1.17beta1 get golang.org/x/net/html
go: downloading golang.org/x/net v0.0.0-20210716203947-853a461950ff

/tmp$

CC @jayconrod @matloob

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go modules labels Jul 19, 2021
@bcmills bcmills added this to the Go1.18 milestone Jul 19, 2021
@bcmills bcmills self-assigned this Jul 19, 2021
@ianlancetaylor
Copy link
Contributor

@bcmills This is in the 1.18 milestone; time to move to 1.19? Thanks.

@bcmills bcmills modified the milestones: Go1.18, Go1.19 Jan 29, 2022
@ianlancetaylor
Copy link
Contributor

@bcmills @matloob This issue is marked for 1.19. It's just been rolling forward in milestones. Should it move to Backlog?

@bcmills bcmills modified the milestones: Go1.19, Backlog Jun 24, 2022
@bcmills bcmills removed their assignment Jun 24, 2022
@ianwoolf
Copy link
Contributor

ianwoolf commented Oct 25, 2022

Now, in 1.19, if go get is invoked in module mode outside of any module, it will do nothing.

https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/cmd/go/internal/modget/get.go;l=295

Seems like no other messages are needed anymore? Or am I missing something. If there is something needs to do, I will work on it

@bcmills
Copy link
Contributor Author

bcmills commented Nov 15, 2022

@ianwoolf, thanks for the ping. It does appear that this is fixed as of Go 1.19:

$ go1.19.3 env GOMOD
/dev/null

$ go1.19.3 get golang.org/x/net/html
go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
@golang golang locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

4 participants