Skip to content

go/version: IsValid reports false on inputs like "go1.8.5rc5", "go1.9.2rc2" #68634

Closed as not planned
@246859

Description

@246859

Go version

go version go1.22.5 windows/amd64

Output of go env in your module/workspace:

$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\work\libs\golang\mods\bin
set GOCACHE=D:\work\libs\golang\cache
set GOENV=D:\work\libs\golang\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\work\libs\golang\mods\libs
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\work\libs\golang\mods
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\work\libs\golang\root\go1.22.5
set GOSUMDB=sum.golang.org
set GOTMPDIR=D:\work\libs\golang\temp
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\work\libs\golang\root\go1.22.5\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=D:\work\libs\golang\temp\go-build838424048=/tmp/go-build -gno-record-gcc-switches

What did you do?

When I try to sort go version list that got from below command

git ls-remote -tags --sort=version:refname https://github.com/golang/go

I got an incredible result that the version go1.8.5rc5 is the minimum version, even less than go1.
The reason is that go/version.IsValid do not consider prerelease patch as valid version, but some prerelease patch really do exist in history versions, such as go1.8.5rc5, go1.8.5rc4, go1.9.2rc2 .The version go1.9.2rc2 even could be discovered from https://go.dev/dl/?mode=json&include=all, and downloaded from https://dl.google.com/go/go1.9.2rc2.linux-amd64.tar.gz, it's very unreasonable to treat it as an invalid version.

Here is a snippset to prove this: https://go.dev/play/p/TBz7px5tMd_8

What did you see happen?

fmt.Println(version.IsValid("go1.9.2rc2"))

output

false

What did you expect to see?

fmt.Println(version.IsValid("go1.9.2rc2"))

output

true

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions