From: cuishuang Date: Mon, 28 Apr 2025 09:00:24 +0000 (+0800) Subject: internal/goroot: replace HasPrefix+TrimPrefix with CutPrefix X-Git-Tag: go1.26rc1~524 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=107fcb70de859f7b8d08ce8bce8cf6a6d944aeff;p=gostls13.git internal/goroot: replace HasPrefix+TrimPrefix with CutPrefix Change-Id: I97305df6babbede57bb0c3b48c89c96cb74307f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/668456 Auto-Submit: Sean Liao Reviewed-by: David Chase Reviewed-by: Sean Liao LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov --- diff --git a/src/internal/goroot/gc.go b/src/internal/goroot/gc.go index 133d076391..534ad57e70 100644 --- a/src/internal/goroot/gc.go +++ b/src/internal/goroot/gc.go @@ -77,8 +77,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, ok := strings.CutPrefix(dirEntry, prefix); ok { + dirs = filepath.SplitList(after) break } }