Skip to content

Commit

Permalink
support to parse devl version
Browse files Browse the repository at this point in the history
Signed-off-by: sivchari <[email protected]>
  • Loading branch information
sivchari authored and aykevl committed Nov 15, 2024
1 parent 258dac2 commit ac9f72b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions goenv/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
1 change: 1 addition & 0 deletions goenv/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ac9f72b

Please sign in to comment.