mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +00:00
cmd/dist: use slices.Index
Change-Id: Ifcab176faa2ac55e60576cf6acd96a18d0e860ab Reviewed-on: https://go-review.googlesource.com/c/go/+/648859 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
baeab452d1
commit
b16c04f439
17
src/cmd/dist/build.go
vendored
17
src/cmd/dist/build.go
vendored
@ -16,6 +16,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -104,16 +105,6 @@ var okgoos = []string{
|
|||||||
"aix",
|
"aix",
|
||||||
}
|
}
|
||||||
|
|
||||||
// find reports the first index of p in l[0:n], or else -1.
|
|
||||||
func find(p string, l []string) int {
|
|
||||||
for i, s := range l {
|
|
||||||
if p == s {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// xinit handles initialization of the various global state, like goroot and goarch.
|
// xinit handles initialization of the various global state, like goroot and goarch.
|
||||||
func xinit() {
|
func xinit() {
|
||||||
b := os.Getenv("GOROOT")
|
b := os.Getenv("GOROOT")
|
||||||
@ -134,7 +125,7 @@ func xinit() {
|
|||||||
b = gohostos
|
b = gohostos
|
||||||
}
|
}
|
||||||
goos = b
|
goos = b
|
||||||
if find(goos, okgoos) < 0 {
|
if slices.Index(okgoos, goos) < 0 {
|
||||||
fatalf("unknown $GOOS %s", goos)
|
fatalf("unknown $GOOS %s", goos)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +193,7 @@ func xinit() {
|
|||||||
if b != "" {
|
if b != "" {
|
||||||
gohostarch = b
|
gohostarch = b
|
||||||
}
|
}
|
||||||
if find(gohostarch, okgoarch) < 0 {
|
if slices.Index(okgoarch, gohostarch) < 0 {
|
||||||
fatalf("unknown $GOHOSTARCH %s", gohostarch)
|
fatalf("unknown $GOHOSTARCH %s", gohostarch)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +202,7 @@ func xinit() {
|
|||||||
b = gohostarch
|
b = gohostarch
|
||||||
}
|
}
|
||||||
goarch = b
|
goarch = b
|
||||||
if find(goarch, okgoarch) < 0 {
|
if slices.Index(okgoarch, goarch) < 0 {
|
||||||
fatalf("unknown $GOARCH %s", goarch)
|
fatalf("unknown $GOARCH %s", goarch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user