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.

Comment From: chenyanchen

The inferred path should be checked

https://github.com/golang/go/blob/4c32b1cc753e9005ed7c741bf69d3cb69ee3a56c/src/cmd/go/internal/modload/init.go#L1078-L1084

Comment From: gabyhelp

Related Issues

Related Code Changes

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: seankhliao

do you want to send a change?

Comment From: chenyanchen

do you want to send a change?

I will try

Comment From: gopherbot

Change https://go.dev/cl/662438 mentions this issue: cmd/go/internal/modload: don't infer a /v1 suffix module path