Open
Description
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.
Activity
chenyanchen commentedon Apr 1, 2025
The inferred path should be checked
go/src/cmd/go/internal/modload/init.go
Lines 1078 to 1084 in 4c32b1c
gabyhelp commentedon Apr 1, 2025
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
[-]`go mod init` cannot init `v1` suffix module, but can infer go module path[/-][+]cmd/go: mod init should not infer a path with a /v1 suffix [/+]seankhliao commentedon Apr 1, 2025
do you want to send a change?
chenyanchen commentedon Apr 2, 2025
I will try
gopherbot commentedon Apr 3, 2025
Change https://go.dev/cl/662438 mentions this issue:
cmd/go/internal/modload: don't infer a /v1 suffix module path