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

[Proposal] cmd/go: when mod=vendor, go get should automatically update the vendor directory #38222

Closed
marwan-at-work opened this issue Apr 2, 2020 · 3 comments

Comments

@marwan-at-work
Copy link
Contributor

Summary

Now that Go 1.14 recognizes the vendor folder automatically, go get operations should automatically populate the vendor folder as well.

This will save programmers from having to do go get <module> && go mod vendor to just doing go get <module> -- It reduces two steps into one and from personal experience, it is what people expect the behavior to be and are surprised when they run into a compilation error and realize they have to run a follow up command aka go mod vendor.

Reasoning

This provides both consistency and better developer experience. If go build automatically uses the vendor folder, then go get should also do the same and therefore go build should succeed.

Question

If this proposal is accepted, should it be scoped to the go get command only and not other commands such as go mod tidy and go list?

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

1.14

Does this issue reproduce with the latest release?

Yes

What did you do?

  • mkdir tempdir && cd tempdir && go mod init tempdir

  • go get github.com/pkg/errors

  • printf 'package main\nimport _ "github.com/pkg/errors"\nfunc main() {}' > main.go

  • go mod vendor

  • go build

  • go get github.com/sirupsen/logrus

  • go build

What did you expect to see?

The vendor directory automatically populated, without having to run a follow up go mod vendor command.

What did you see instead?

go: inconsistent vendoring in /tempdir:
        github.com/sirupsen/logrus@v1.5.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
@mvdan
Copy link
Member

mvdan commented Apr 2, 2020

CC @FiloSottile @bcmills from #29058

@bcmills
Copy link
Contributor

bcmills commented Apr 2, 2020

See #30240 (comment) for our previous rationale.

@bcmills
Copy link
Contributor

bcmills commented Apr 2, 2020

Duplicate of #29058

@bcmills bcmills marked this as a duplicate of #29058 Apr 2, 2020
@bcmills bcmills closed this as completed Apr 2, 2020
@golang golang locked and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants