Skip to content

cmd/go: mod init should not infer a path with a /v1 suffix  #73121

Open
@chenyanchen

Description

@chenyanchen

Go version

go version go1.24.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/***/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/***/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tp/t2jb95_s2_52x00_183fbc2h0000gn/T/go-build470510512=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/***/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/***/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.1/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/***/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

In ${GOPATH}/src

$ mkdir -p example.com/project/v1
$ cd example.com/project/v1
$ go mod init example.com/project/v1
go: invalid module path "example.com/project/v1": major version suffixes must be in the form of /vN and are only allowed for v2 or later:
	go mod init example.com/project/v2
$ go mod init
go: creating new go.mod: module example.com/project/v1
$ cat go.mod
module example.com/project/v1

go 1.24.1

What did you see happen?

go mod init example.com/project/v1 failed

go mod init success

What did you expect to see?

Refer the go mod init example.com/project/v1 error, go mod init should failed too.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/go

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions