-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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/fmt: tries to download dependencies #31976
Labels
Comments
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
go version go1.12 linux/amd64
go env
OutputWhat did you do?
Create a tiny package using modules:
foo.go
go.mod
Clear the module cache:
Disconnect from the Internet.
Run
go fmt
:What did you expect to see?
A successful run of
go fmt
.What did you see instead?
An error message.
It appears that
go fmt
attempts to download all module dependencies if they aren't present. However, as far as I can tell, there is no reason forgo fmt
to do this, since it doesn't process dependencies at all; it just changes the formatting of a single file (or a group of files).At a minimum,
go fmt
should obeyGOFLAGS=-mod=readonly
, but I think even when that's not present, it shouldn't attempt to download dependencies.This came up in practice on the Boulder project, where we vendor our dependencies and run tests inside a container that does not have Internet access. One of those tests is a check for correct formatting with
go fmt
.The text was updated successfully, but these errors were encountered: