From 789e798f0436361bfe8ca492a933cfeb17d2780c Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Tue, 27 Sep 2022 15:58:33 +0800 Subject: [PATCH] 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 TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Bryan Mills --- src/internal/goroot/gc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/goroot/gc.go b/src/internal/goroot/gc.go index 79403d29fc..5517598519 100644 --- a/src/internal/goroot/gc.go +++ b/src/internal/goroot/gc.go @@ -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 } }