diff options
author | Kyle Wood <kyle@kylewood.cc> | 2018-11-16 10:46:14 -0600 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2018-12-07 22:42:18 +0000 |
commit | 179909f20556262422a8b99c059eacdfcebc48ee (patch) | |
tree | ac64ca56cb0dcee9a99ded7a94074b269e7f389b /src/cmd/go/internal/modcmd/init.go | |
parent | 444887dde8393c3bbf94122c17ab7f005a7257c4 (diff) | |
download | go-179909f20556262422a8b99c059eacdfcebc48ee.tar.gz go-179909f20556262422a8b99c059eacdfcebc48ee.zip |
cmd/go: disallow version string in go mod init module path
To prevent confusion, go mod init should not allow version strings in
the module path when provided as an argument. Instead, fail with a
useful error message.
Fixes #28803
Change-Id: I59272a91b042e32cef33c2e2116f760ca1def218
Reviewed-on: https://go-review.googlesource.com/c/150018
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modcmd/init.go')
-rw-r--r-- | src/cmd/go/internal/modcmd/init.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modcmd/init.go b/src/cmd/go/internal/modcmd/init.go index f510a46262..0f7421e584 100644 --- a/src/cmd/go/internal/modcmd/init.go +++ b/src/cmd/go/internal/modcmd/init.go @@ -10,6 +10,7 @@ import ( "cmd/go/internal/base" "cmd/go/internal/modload" "os" + "strings" ) var cmdInit = &base.Command{ @@ -37,5 +38,8 @@ func runInit(cmd *base.Command, args []string) { if _, err := os.Stat("go.mod"); err == nil { base.Fatalf("go mod init: go.mod already exists") } + if strings.Contains(modload.CmdModModule, "@") { + base.Fatalf("go mod init: module path must not contain '@'") + } modload.InitMod() // does all the hard work } |