-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.release-blocker
Milestone
Description
Version
golang.org/x/tools v0.39.0
What did you do?
I run the stringscut analyzer (though golangci-lint) on the code snippets above.
What did you see happen?
$ golangci-lint run --enable-only modernize
foo.go:29:10: stringscut: strings.IndexByte can be simplified using strings.Cut (modernize)
if i := strings.IndexByte(s, '='); i > 0 {
^
1 issues:
* modernize: 1$ golangci-lint run --enable-only modernize
bar.go:21:10: stringscut: strings.Index can be simplified using strings.Cut (modernize)
if i := strings.Index(a, b); i > 0 {
^
1 issues:
* modernize: 1What did you expect to see?
As you can see in the code snippet, the analyzer suggests something that is not equivalent to the original functions.
## Cut
abc true
a bc true
abc true
## Original
=abc false
a bc true
abc true
## Modified
abc true
a bc true
abc true## Original
b
## Modified
b
bMetadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.release-blocker