go-tools icon indicating copy to clipboard operation
go-tools copied to clipboard

simple: flag uses of strings.CutPrefix/CutSuffix that should use strings.TrimPrefix/TrimSuffix instead

Open cespare opened this issue 1 year ago • 0 comments

Since the introduction of strings.CutPrefix and strings.CutSuffix I've started noticing code that should use strings.TrimPrefix/strings.TrimSuffix instead:

x, _ := strings.CutPrefix(y, "abc")

I just implemented the trivial analyzer for this for our internal lint tool. Might be a nice (tiny) addition to staticcheck.

cespare avatar Sep 26 '24 07:09 cespare