Skip to content

Commit ff9a799

Browse files
committed
1 parent 36554d1 commit ff9a799

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

go/extractor/toolchain/toolchain.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ func parseGoVersion(data string) string {
130130
for sc.Scan() {
131131
lastLine = sc.Text()
132132
}
133-
return strings.Fields(lastLine)[2]
133+
134+
var goVersion = strings.Fields(lastLine)[2]
135+
136+
// Drop custom build suffixes.
137+
goVersion, _, _ = strings.Cut(goVersion, "-")
138+
139+
return goVersion
134140
}
135141

136142
// Returns a value indicating whether the system Go toolchain supports workspaces.

go/extractor/toolchain/toolchain_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
func TestParseGoVersion(t *testing.T) {
1010
tests := map[string]string{
1111
"go version go1.18.9 linux/amd64": "go1.18.9",
12+
"go version go1.26.3-X:nodwarf5 linux/amd64": "go1.26.3",
13+
"go version go1.26.3rc1 linux/amd64": "go1.26.3rc1",
1214
"warning: GOPATH set to GOROOT (/usr/local/go) has no effect\ngo version go1.18.9 linux/amd64": "go1.18.9",
1315
}
1416
for input, expected := range tests {

0 commit comments

Comments
 (0)