diff --git a/cli/cli.go b/cli/cli.go index 51c0517..e1fc156 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -130,13 +130,19 @@ func installed() (versions map[string]bool) { return } +var go1_21_0 = semver.MustParse("1.21.0") // https://github.com/golang/go/issues/57631 + // render 渲染go版本列表 func render(installed map[string]bool, items []*semver.Version, out io.Writer) { sort.Sort(semver.Collection(items)) for i := range items { fields := strings.SplitN(items[i].String(), "-", 2) - v := strings.TrimSuffix(strings.TrimSuffix(fields[0], ".0"), ".0") + + v := fields[0] + if items[i].LessThan(go1_21_0) { + v = strings.TrimSuffix(strings.TrimSuffix(v, ".0"), ".0") + } if len(fields) > 1 { v += fields[1] }