internal/goroot: using strings.CutPrefix replace strings.HasPrefix and strings.TrimPrefix

Change-Id: I63b2af955e2ada6d20e72c10797576d93bbc7e71
Reviewed-on: https://go-review.googlesource.com/c/go/+/435135
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
cuiweixie 2022-09-27 15:58:33 +08:00 committed by Gopher Robot
parent fac5338a6c
commit 789e798f04

View file

@ -69,8 +69,8 @@ func (gd *gccgoDirs) init() {
const prefix = "libraries: ="
var dirs []string
for _, dirEntry := range dirsEntries {
if strings.HasPrefix(dirEntry, prefix) {
dirs = filepath.SplitList(strings.TrimPrefix(dirEntry, prefix))
if after, found := strings.CutPrefix(dirEntry, prefix); found {
dirs = filepath.SplitList(after)
break
}
}