go/version: use "custom" as an example of a version suffix

The suffix in a non-standard toolchain version can be any string. Show
more of a middle ground example of a non-standard version suffix,
aligning it with the example used at https://go.dev/doc/toolchain#name.

For #75953.

Change-Id: I98f9c4de98316aecf76c017eb13cf25582c8939c
Reviewed-on: https://go-review.googlesource.com/c/go/+/720621
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Dmitri Shuralyov 2025-11-14 15:40:43 -05:00
parent c4bb9653ba
commit ab59569099

View file

@ -4,7 +4,7 @@
// 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".
// "go1.20", "go1.21.0", "go1.22rc2", and "go1.23.4-custom".
//
// [Go versions]: https://go.dev/doc/toolchain#version
// [Go toolchain name syntax]: https://go.dev/doc/toolchain#name
@ -15,10 +15,10 @@ import (
"strings"
)
// stripGo converts from a "go1.21-bigcorp" version to a "1.21" version.
// stripGo converts from a "go1.21-custom" 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.
v, _, _ = strings.Cut(v, "-") // strip -custom suffix.
if len(v) < 2 || v[:2] != "go" {
return ""
}