]> Cypherpunks repositories - gostls13.git/commit
cmd/go: only generate a go.mod file during 'go mod init'
authorBryan C. Mills <bcmills@google.com>
Wed, 13 Feb 2019 22:37:50 +0000 (17:37 -0500)
committerBryan C. Mills <bcmills@google.com>
Fri, 15 Feb 2019 17:32:07 +0000 (17:32 +0000)
commit65c2069a9f30cb6fa2c512d17dc0ad654d621da9
tree0db5138f041fb3adcb3257a23666b598a5436180
parent4c89a10fb9f4fcb2ed01b6e7325e53b4bc487fc2
cmd/go: only generate a go.mod file during 'go mod init'

In the general case, we do not know the correct module path for a new
module unless we have checked its VCS tags for a major version. If we
do not know the correct path, then we should not synthesize a go.mod
file automatically from it.

On the other hand, we don't want to run VCS commands in the working
directory without an explicit request by the user to do so: 'go mod
init' can reasonably invoke a VCS command, but 'go build' should not.

Therefore, we should only create a go.mod file during 'go mod init'.

This change removes the previous behavior of synthesizing a file
automatically, and instead suggests a command that the user can opt to
run explicitly.

Updates #29433
Updates #27009
Updates #30228

Change-Id: I8c4554969db17156e97428df220b129a4d361040
Reviewed-on: https://go-review.googlesource.com/c/162699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
14 files changed:
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/init_test.go [deleted file]
src/cmd/go/internal/modload/load.go
src/cmd/go/testdata/script/mod_convert_dep.txt
src/cmd/go/testdata/script/mod_convert_git.txt
src/cmd/go/testdata/script/mod_convert_glide.txt
src/cmd/go/testdata/script/mod_convert_glockfile.txt
src/cmd/go/testdata/script/mod_convert_godeps.txt
src/cmd/go/testdata/script/mod_convert_tsv.txt
src/cmd/go/testdata/script/mod_convert_vendor_conf.txt
src/cmd/go/testdata/script/mod_convert_vendor_json.txt
src/cmd/go/testdata/script/mod_convert_vendor_manifest.txt
src/cmd/go/testdata/script/mod_convert_vendor_yml.txt
src/cmd/go/testdata/script/mod_find.txt