cmd/go: go fmt shouldn't send network request in module mode #30975
Labels
FrozenDueToAge
GoCommand
cmd/go
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?master branch, 0fe1986
Does this issue reproduce with the latest release?
Partially.
What did you do?
And then there are three situations.
cd ~/test; go fmt
cd ~/test; go fmt ./main.go
cd ~; go fmt ~/test/main.go
What did you expect to see?
go fmt
reformats the filemain.go
in the three situations.If I didn't run
go mod init github.com/a/b
, everything works fine.What did you see instead?
On master branch, with commit eca5c83,
go fmt
runsgit ls-remote -q https://github.com/a/b
and fails in the three situations.Go1.12 fails in situation 1 and 2, and it succeeds in situation 3.
I think there are two things to be fixed.
go fmt
doesn't need to find packagegithub.com/a/b/c
and it shouldn't rungit
. It can just reformat the file.github.com/a/b
is in the directory~/test
and I am doing something with~/test
(such ascd ~/test; go build
),go
should look forgithub.com/a/b
andgithub.com/a/b/c
in~/test
. It shouldn't usegit
or requestgithub.com
to find the current module.The text was updated successfully, but these errors were encountered: