diff options
| author | Jonathan Amsterdam <jba@google.com> | 2019-11-01 16:30:21 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-03-27 16:46:46 -0400 |
| commit | b322ae09c0174ecd3686861ae1185d6844b281fd (patch) | |
| tree | 501caf6b98bd011443d1a4cbeb28a054cc441f0b /internal/stdlib/stdlib.go | |
| parent | 34a56cf3dc22ba8973b8379a4e307a0519500195 (diff) | |
| download | go-x-pkgsite-b322ae09c0174ecd3686861ae1185d6844b281fd.tar.xz | |
internal/frontend: fix major version for std
Display the major version as "go1", not "v1".
Also, fix the tooltip.
Fixes b/143529585.
Fixes b/143613230.
Change-Id: I3379e8295a90f79c375f6e54e3593eee2391a335
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/589902
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Diffstat (limited to 'internal/stdlib/stdlib.go')
| -rw-r--r-- | internal/stdlib/stdlib.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/stdlib/stdlib.go b/internal/stdlib/stdlib.go index f73561ac..8a081cfc 100644 --- a/internal/stdlib/stdlib.go +++ b/internal/stdlib/stdlib.go @@ -105,6 +105,22 @@ func TagForVersion(version string) (_ string, err error) { return goVersion, nil } +// MajorVersionForVersion returns the Go major version for version. +// E.g. "v1.13.3" => "go1". +func MajorVersionForVersion(version string) (_ string, err error) { + defer derrors.Wrap(&err, "MajorTagForVersion(%q)", version) + + tag, err := TagForVersion(version) + if err != nil { + return "", err + } + i := strings.IndexRune(tag, '.') + if i < 0 { + return "", fmt.Errorf("no '.' in go tag %q", tag) + } + return tag[:i], nil +} + // finalDigitsIndex returns the index of the first digit in the sequence of digits ending s. // If s doesn't end in digits, it returns -1. func finalDigitsIndex(s string) int { |
