mirror of
https://github.com/golang/go
synced 2024-09-29 00:24:30 -06:00
cmd/go/internal/get: remove unused tag selection code
selectTag has been hard coded to only understand the tag `go1` since CL 6112060 which landed in 2012. The commit message asserted; Right now (before go1.0.1) there is only one possible tag, "go1", and I'd like to keep it that way. Remove goTag and the unused matching code in selectTag. Change-Id: I85f7c10f95704e22f8e8681266afd72bbcbe8fbd Reviewed-on: https://go-review.googlesource.com/38112 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
7ee43faf78
commit
d5a9fbd556
@ -10,9 +10,7 @@ import (
|
||||
"go/build"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"cmd/go/internal/base"
|
||||
@ -508,14 +506,6 @@ func downloadPackage(p *load.Package) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// goTag matches go release tags such as go1 and go1.2.3.
|
||||
// The numbers involved must be small (at most 4 digits),
|
||||
// have no unnecessary leading zeros, and the version cannot
|
||||
// end in .0 - it is go1, not go1.0 or go1.0.0.
|
||||
var goTag = regexp.MustCompile(
|
||||
`^go((0|[1-9][0-9]{0,3})\.)*([1-9][0-9]{0,3})$`,
|
||||
)
|
||||
|
||||
// selectTag returns the closest matching tag for a given version.
|
||||
// Closest means the latest one that is not after the current release.
|
||||
// Version "goX" (or "goX.Y" or "goX.Y.Z") matches tags of the same form.
|
||||
@ -531,56 +521,4 @@ func selectTag(goVersion string, tags []string) (match string) {
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
||||
/*
|
||||
if goTag.MatchString(goVersion) {
|
||||
v := goVersion
|
||||
for _, t := range tags {
|
||||
if !goTag.MatchString(t) {
|
||||
continue
|
||||
}
|
||||
if cmpGoVersion(match, t) < 0 && cmpGoVersion(t, v) <= 0 {
|
||||
match = t
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match
|
||||
*/
|
||||
}
|
||||
|
||||
// cmpGoVersion returns -1, 0, +1 reporting whether
|
||||
// x < y, x == y, or x > y.
|
||||
func cmpGoVersion(x, y string) int {
|
||||
// Malformed strings compare less than well-formed strings.
|
||||
if !goTag.MatchString(x) {
|
||||
return -1
|
||||
}
|
||||
if !goTag.MatchString(y) {
|
||||
return +1
|
||||
}
|
||||
|
||||
// Compare numbers in sequence.
|
||||
xx := strings.Split(x[len("go"):], ".")
|
||||
yy := strings.Split(y[len("go"):], ".")
|
||||
|
||||
for i := 0; i < len(xx) && i < len(yy); i++ {
|
||||
// The Atoi are guaranteed to succeed
|
||||
// because the versions match goTag.
|
||||
xi, _ := strconv.Atoi(xx[i])
|
||||
yi, _ := strconv.Atoi(yy[i])
|
||||
if xi < yi {
|
||||
return -1
|
||||
} else if xi > yi {
|
||||
return +1
|
||||
}
|
||||
}
|
||||
|
||||
if len(xx) < len(yy) {
|
||||
return -1
|
||||
}
|
||||
if len(xx) > len(yy) {
|
||||
return +1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user