diff options
author | Russ Cox <rsc@golang.org> | 2021-09-22 10:46:32 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-10-06 15:53:04 +0000 |
commit | 4d8db00641cc9ff4f44de7df9b8c4f4a4f9416ee (patch) | |
tree | 1e850efb295d4c5f0589e46bd8d9f1930d4af0b5 /misc/linkcheck | |
parent | 8e36ab055162efa6f67f3b9ee62f625ac8874901 (diff) | |
download | go-4d8db00641cc9ff4f44de7df9b8c4f4a4f9416ee.tar.gz go-4d8db00641cc9ff4f44de7df9b8c4f4a4f9416ee.zip |
all: use bytes.Cut, strings.Cut
Many uses of Index/IndexByte/IndexRune/Split/SplitN
can be written more clearly using the new Cut functions.
Do that. Also rewrite to other functions if that's clearer.
For #46336.
Change-Id: I68d024716ace41a57a8bf74455c62279bde0f448
Reviewed-on: https://go-review.googlesource.com/c/go/+/351711
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'misc/linkcheck')
-rw-r--r-- | misc/linkcheck/linkcheck.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/misc/linkcheck/linkcheck.go b/misc/linkcheck/linkcheck.go index 570b430da4..efe400965b 100644 --- a/misc/linkcheck/linkcheck.go +++ b/misc/linkcheck/linkcheck.go @@ -81,10 +81,8 @@ func crawl(url string, sourceURL string) { } mu.Lock() defer mu.Unlock() - var frag string - if i := strings.Index(url, "#"); i >= 0 { - frag = url[i+1:] - url = url[:i] + if u, frag, ok := strings.Cut(url, "#"); ok { + url = u if frag != "" { uf := urlFrag{url, frag} neededFrags[uf] = append(neededFrags[uf], sourceURL) |