-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: fmt does not respect or have defined -mod #27841
Comments
I think you have some sort of environment issue here. The following works for me:
gives the output:
|
@myitcv I think you missed the step to remove the cached modules. Without the step, the cache is being used, ignoring Modifying your example to include changing to a new GOPATH. Using
Gives output:
|
I did indeed forget to ask why you had included that :) Makes sense now, thanks. cc @rsc @bcmills to confirm expected behaviour here. I suspect this is also an issue for the other tools (
You probably wanted |
Yes. Thank you. That would have made the example clearer. |
Most commands take all the build flags (documented in |
I tried using the env form, but that did not work out as hoped... export GOFLAGS="-mod=vendor" //go:generate go fmt ./... go generate ./... Still downloaded loads of stuff instead of using the vendor directory. |
Fixes golang#27841 Change-Id: Ifcfd938aff8680cf7b44dfc09fde01d6105345a0
Change https://golang.org/cl/198257 mentions this issue: |
`go fmt` doesn't seem to respect `-mod=vendor` golang/go#27841 Instead try using `gofmt` which doesn't trigger downloading dependencies in the first place. However, `gofmt` affects files under `vendor/`, so we reset that before checking for changes.
This removes network loads until `go fmt` stops trying to download those resources. golang/go#27841 has more information.
What version of Go are you using (
go version
)?go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes. 1.11 is the current latest release
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
This demonstrates that we have an example program using the vendor directory and
GOPROXY
is set to off.Now we want to run
go fmt
try using
-mod=vendor
try using
gofmt
What did you expect to see?
go fmt
should format source files usinggofmt -l -w .
. The documentation indicates:What did you see instead?
Instead of
go fmt
runninggofmt -l -w .
it first tries to load modules ignoring-mod=vendor
. It is also unclear whygo fmt
requires loading modules if it just runsgofmt
which works without loading modules.The text was updated successfully, but these errors were encountered: