Skip to content

Commit

Permalink
fix: use a zero for third digit for major release. #105
Browse files Browse the repository at this point in the history
  • Loading branch information
voidint committed Aug 9, 2023
1 parent 128d04a commit b2ae845
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,23 @@ func inuse(goroot string) (version string) {
return filepath.Base(p)
}

var go1_21_0 = semver.MustParse("1.21.0") // https://github.com/golang/go/issues/57631

// render 渲染go版本列表
func render(curV string, 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]
}

if v == curV {
color.New(color.FgGreen).Fprintf(out, "* %s\n", v)
} else {
Expand Down

0 comments on commit b2ae845

Please sign in to comment.