From ac9f72be617e6e72423fa7afd6bcd2aaf9377d27 Mon Sep 17 00:00:00 2001 From: sivchari Date: Fri, 15 Nov 2024 15:39:22 +0900 Subject: [PATCH] support to parse devl version Signed-off-by: sivchari --- goenv/version.go | 3 +++ goenv/version_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/goenv/version.go b/goenv/version.go index 158c3caf20..4815d434a3 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -50,6 +50,9 @@ func GetGorootVersion() (major, minor int, err error) { // major, minor, and patch version: 1, 3, and 2 in this example. // If there is an error, (0, 0, 0) and an error will be returned. func Parse(version string) (major, minor, patch int, err error) { + if strings.HasPrefix(version, "devel ") { + version = strings.Split(strings.TrimPrefix(version, "devel "), version)[0] + } if version == "" || version[:2] != "go" { return 0, 0, 0, errors.New("could not parse Go version: version does not start with 'go' prefix") } diff --git a/goenv/version_test.go b/goenv/version_test.go index 1744d2b22f..cb408a2eae 100644 --- a/goenv/version_test.go +++ b/goenv/version_test.go @@ -21,6 +21,7 @@ func TestParse(t *testing.T) { {"go1.23.5-rc6", 1, 23, 5, false}, {"go2.0", 2, 0, 0, false}, {"go2.0.15", 2, 0, 15, false}, + {"devel go1.24-f99f5da18f Thu Nov 14 22:29:26 2024 +0000 darwin/arm64", 1, 24, 0, false}, } for _, tt := range tests { t.Run(tt.v, func(t *testing.T) {