aboutsummaryrefslogtreecommitdiff
path: root/src/go/version/version.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/version/version.go')
-rw-r--r--src/go/version/version.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/go/version/version.go b/src/go/version/version.go
index 466c8091ea..6b8ee67442 100644
--- a/src/go/version/version.go
+++ b/src/go/version/version.go
@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package version provides operations on [Go versions].
+// Package version provides operations on [Go versions]
+// in [Go toolchain name syntax]: strings like
+// "go1.20", "go1.21.0", "go1.22rc2", and "go1.23.4-bigcorp".
//
// [Go versions]: https://go.dev/doc/toolchain#version
+// [Go toolchain name syntax]: https://go.dev/doc/toolchain#name
package version // import "go/version"
import (
@@ -12,9 +15,10 @@ import (
"strings"
)
-// stripGo converts from a "go1.21" version to a "1.21" version.
+// stripGo converts from a "go1.21-bigcorp" version to a "1.21" version.
// If v does not start with "go", stripGo returns the empty string (a known invalid version).
func stripGo(v string) string {
+ v, _, _ = strings.Cut(v, "-") // strip -bigcorp suffix.
if len(v) < 2 || v[:2] != "go" {
return ""
}
@@ -50,8 +54,6 @@ func Lang(x string) string {
// valid versions and equal to each other.
// The language version "go1.21" compares less than the
// release candidate and eventual releases "go1.21rc1" and "go1.21.0".
-// Custom toolchain suffixes are ignored during comparison:
-// "go1.21.0" and "go1.21.0-bigcorp" are equal.
func Compare(x, y string) int {
return gover.Compare(stripGo(x), stripGo(y))
}