]> Cypherpunks repositories - gostls13.git/commit
cmd/go: explicitly reject module paths "go" and "toolchain"
authorMichael Matloob <matloob@golang.org>
Tue, 29 Jul 2025 18:17:33 +0000 (14:17 -0400)
committerMichael Matloob <matloob@golang.org>
Thu, 31 Jul 2025 18:00:08 +0000 (11:00 -0700)
commitc0ee2fd4e309ef0b8f4ab6f4860e2626c8e00802
tree8e0823417fb246639d02749a4ac59c708db044f5
parenta4d99770c0e5f340d6d11d6353110413dc109138
cmd/go: explicitly reject module paths "go" and "toolchain"

The module paths "go" and "toolchain" are reserved for the dependency on
the go and toolchain versions. Check for those paths in go mod init to
create modules, go mod edit, and in the module loader and return an
error when attempting to use those paths for a work module. Trying to
init or load a work module with a go.mod that specifies the module path
"go" panics since Go 1.21 (when the toolchain switching logic and the
implicit dependencies on the "go" module was introduced), and this
change returns a proper error instead of panicking.

Fixes #74784

Change-Id: I10e712f8fddbea63edaeb37e14c6d783722e623f
Reviewed-on: https://go-review.googlesource.com/c/go/+/691515
Reviewed-by: Ian Alexander <jitsu@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
src/cmd/go/internal/modcmd/edit.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/modfile.go
src/cmd/go/testdata/script/mod_init_issue74784.txt [new file with mode: 0644]