mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +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
|
// process header lines
|
||||||
for data != "" {
|
for data != "" {
|
||||||
var line string
|
var line string
|
||||||
if i := strings.Index(data, "\n"); i >= 0 {
|
line, data, _ = strings.Cut(data, "\n")
|
||||||
line, data = data[:i], data[i+1:]
|
|
||||||
} else {
|
|
||||||
line, data = data, ""
|
|
||||||
}
|
|
||||||
if line == "main" {
|
if line == "main" {
|
||||||
lib.Main = true
|
lib.Main = true
|
||||||
}
|
}
|
||||||
@ -141,8 +137,8 @@ func setCgoAttr(ctxt *Link, file string, pkg string, directives [][]string, host
|
|||||||
}
|
}
|
||||||
|
|
||||||
q := ""
|
q := ""
|
||||||
if i := strings.Index(remote, "#"); i >= 0 {
|
if before, after, found := strings.Cut(remote, "#"); found {
|
||||||
remote, q = remote[:i], remote[i+1:]
|
remote, q = before, after
|
||||||
}
|
}
|
||||||
s := l.LookupOrCreateSym(local, 0)
|
s := l.LookupOrCreateSym(local, 0)
|
||||||
st := l.SymType(s)
|
st := l.SymType(s)
|
||||||
|
@ -62,15 +62,13 @@ func (ctxt *Link) readImportCfg(file string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var verb, args string
|
verb, args, found := strings.Cut(line, " ")
|
||||||
if i := strings.Index(line, " "); i < 0 {
|
if found {
|
||||||
verb = line
|
args = strings.TrimSpace(args)
|
||||||
} else {
|
|
||||||
verb, args = line[:i], strings.TrimSpace(line[i+1:])
|
|
||||||
}
|
}
|
||||||
var before, after string
|
before, after, exist := strings.Cut(args, "=")
|
||||||
if i := strings.Index(args, "="); i >= 0 {
|
if !exist {
|
||||||
before, after = args[:i], args[i+1:]
|
before = ""
|
||||||
}
|
}
|
||||||
switch verb {
|
switch verb {
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user