-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 mod download' should not modify the go.mod file #34450
Comments
See also #26850 (comment). Separately, if you want to disable downloads entirely, you can do GOPROXY=off, which then should cause a command to fail if it needs to download something. |
I don't necessarily want to stop all downloads, it's going to need to happen in a CI/CD pipeline. I'm looking to make sure the
|
@jpreese In this case, I still feel like As I understand it, if Do you have a scenario where /cc @bcmills @jayconrod |
This is closely related to #31372, in that it describes a situation in which a Perhaps it should not. (See #31372 (comment).) |
Yes this is pretty much the same request, but with the |
Workaround: use In my Travis-CI build I use this:
|
@dolmen yep, this was a similar thought I had. Just check to see in the pipeline if the Just wanted to create this issue so the Go team knew and it was documented, since I believe this flag should be supported. Even better, just make it so the default behavior is to fail if the |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Attempted to run
go mod download -mod=readonly
and was given an errorWhat did you expect to see?
The
go mod download
command to run to completion, downloading the required modules in go.modWhat did you see instead?
An error stating that this flag is not supported
Reasoning
Succinctly, it's currently possible that when building a Go application in a Dockerfile, CI/CD pipeline, etc that the go.mod file is updated on the fly. This causes a potential difference in the go.mod file that's located on the local machine/source repository, then what is built post-commit.
It is currently possible to use this flag with
go build
, but copyinggo.mod
andgo.sum
, followed by ago mod download
is a common pattern when using Dockerfiles.Additional discussion from the twitterverse: https://twitter.com/FiloSottile/status/1175135833424351234
The text was updated successfully, but these errors were encountered: