diff options
| author | apocelipes <seve3r@outlook.com> | 2024-01-23 16:33:12 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-01-23 20:08:07 +0000 |
| commit | b3acaa8230e95c232a6f5c30eb7619a0c859ab16 (patch) | |
| tree | 86097d97515a884e1c06690104c911783f7fb208 | |
| parent | 9368ced7555d9320e93e83e18a67faa9af1226b9 (diff) | |
| download | go-b3acaa8230e95c232a6f5c30eb7619a0c859ab16.tar.xz | |
cmd/go/internal/str,cmd/go/internal/work: remove redundant Contains
"cmd/go/internal/str.Contains" does the same thing as the "slices.Contains".
The name "str.Contains" is also easily confused with "strings.Contains".
Given that the slices package is already used in the package,
replace "str.Contains" with "slices.Contains".
"str.Contains" is no longer used so just remove it.
Change-Id: I80572464bd17d4a60e7ff41db3a77c4d0bd03fa3
GitHub-Last-Rev: e74d333f0fd4b9558382e9dba0f77717089f45a9
GitHub-Pull-Request: golang/go#64136
Reviewed-on: https://go-review.googlesource.com/c/go/+/542416
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
| -rw-r--r-- | src/cmd/go/internal/str/str.go | 10 | ||||
| -rw-r--r-- | src/cmd/go/internal/work/exec.go | 4 |
2 files changed, 2 insertions, 12 deletions
diff --git a/src/cmd/go/internal/str/str.go b/src/cmd/go/internal/str/str.go index af7c699972..94be202ba2 100644 --- a/src/cmd/go/internal/str/str.go +++ b/src/cmd/go/internal/str/str.go @@ -88,16 +88,6 @@ func FoldDup(list []string) (string, string) { return "", "" } -// Contains reports whether x contains s. -func Contains(x []string, s string) bool { - for _, t := range x { - if t == s { - return true - } - } - return false -} - // Uniq removes consecutive duplicate strings from ss. func Uniq(ss *[]string) { if len(*ss) <= 1 { diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index e05471b06c..f6aa2b3534 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -3069,12 +3069,12 @@ func (b *Builder) dynimport(a *Action, objdir, importGo, cgoExe string, cflags, ldflags := cgoLDFLAGS if (cfg.Goarch == "arm" && cfg.Goos == "linux") || cfg.Goos == "android" { - if !str.Contains(ldflags, "-no-pie") { + if !slices.Contains(ldflags, "-no-pie") { // we need to use -pie for Linux/ARM to get accurate imported sym (added in https://golang.org/cl/5989058) // this seems to be outdated, but we don't want to break existing builds depending on this (Issue 45940) ldflags = append(ldflags, "-pie") } - if str.Contains(ldflags, "-pie") && str.Contains(ldflags, "-static") { + if slices.Contains(ldflags, "-pie") && slices.Contains(ldflags, "-static") { // -static -pie doesn't make sense, and causes link errors. // Issue 26197. n := make([]string, 0, len(ldflags)-1) |
