mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +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"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -104,16 +105,6 @@ var okgoos = []string{
|
||||
"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.
|
||||
func xinit() {
|
||||
b := os.Getenv("GOROOT")
|
||||
@ -134,7 +125,7 @@ func xinit() {
|
||||
b = gohostos
|
||||
}
|
||||
goos = b
|
||||
if find(goos, okgoos) < 0 {
|
||||
if slices.Index(okgoos, goos) < 0 {
|
||||
fatalf("unknown $GOOS %s", goos)
|
||||
}
|
||||
|
||||
@ -202,7 +193,7 @@ func xinit() {
|
||||
if b != "" {
|
||||
gohostarch = b
|
||||
}
|
||||
if find(gohostarch, okgoarch) < 0 {
|
||||
if slices.Index(okgoarch, gohostarch) < 0 {
|
||||
fatalf("unknown $GOHOSTARCH %s", gohostarch)
|
||||
}
|
||||
|
||||
@ -211,7 +202,7 @@ func xinit() {
|
||||
b = gohostarch
|
||||
}
|
||||
goarch = b
|
||||
if find(goarch, okgoarch) < 0 {
|
||||
if slices.Index(okgoarch, goarch) < 0 {
|
||||
fatalf("unknown $GOARCH %s", goarch)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user