mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/link/internal/ld: use strings.Cut
Change-Id: I724fe76983ea259f12f073376d591c2f4b3c3d72 GitHub-Last-Rev: e61e865ba97a52d24d3aee7642f5804916e94544 GitHub-Pull-Request: golang/go#55910 Reviewed-on: https://go-review.googlesource.com/c/go/+/435738 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
6d5c9f2f26
commit
9f8f1ca5ad
@ -50,11 +50,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, filename s
|
||||
// process header lines
|
||||
for data != "" {
|
||||
var line string
|
||||
if i := strings.Index(data, "\n"); i >= 0 {
|
||||
line, data = data[:i], data[i+1:]
|
||||
} else {
|
||||
line, data = data, ""
|
||||
}
|
||||
line, data, _ = strings.Cut(data, "\n")
|
||||
if line == "main" {
|
||||
lib.Main = true
|
||||
}
|
||||
@ -141,8 +137,8 @@ func setCgoAttr(ctxt *Link, file string, pkg string, directives [][]string, host
|
||||
}
|
||||
|
||||
q := ""
|
||||
if i := strings.Index(remote, "#"); i >= 0 {
|
||||
remote, q = remote[:i], remote[i+1:]
|
||||
if before, after, found := strings.Cut(remote, "#"); found {
|
||||
remote, q = before, after
|
||||
}
|
||||
s := l.LookupOrCreateSym(local, 0)
|
||||
st := l.SymType(s)
|
||||
|
@ -62,15 +62,13 @@ func (ctxt *Link) readImportCfg(file string) {
|
||||
continue
|
||||
}
|
||||
|
||||
var verb, args string
|
||||
if i := strings.Index(line, " "); i < 0 {
|
||||
verb = line
|
||||
} else {
|
||||
verb, args = line[:i], strings.TrimSpace(line[i+1:])
|
||||
verb, args, found := strings.Cut(line, " ")
|
||||
if found {
|
||||
args = strings.TrimSpace(args)
|
||||
}
|
||||
var before, after string
|
||||
if i := strings.Index(args, "="); i >= 0 {
|
||||
before, after = args[:i], args[i+1:]
|
||||
before, after, exist := strings.Cut(args, "=")
|
||||
if !exist {
|
||||
before = ""
|
||||
}
|
||||
switch verb {
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user