-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ReplaceAll #872
Comments
Looks like a subcase of
|
|
If I get this correctly, this is already included in go-critic, the only thing that could be improved is, the suggestion should only happen, if a version of Go >= 1.12 is used. |
I think it's not that hard to add. |
It would be really nice if the go version in |
We're using the model that most Go linters use right now: target Go version is specified using the |
functional replacement for https://golang.org/pkg/strings/#Replace to https://golang.org/pkg/strings/#ReplaceAll since 1.31 golangci-lint gocritic was updated to include replace to replaceall hint. ReplaceAll was added in Go 1.12 See go-critic/go-critic#872 for more.
- deprecated rReplace (with n set to -1) go-critic/go-critic#872
- deprecated rReplace (with n set to -1) go-critic/go-critic#872
Since Go version 1.12,
strings.ReplaceAll
andbytes.ReplaceAll
are available. These should be preferred over their predecessorsReplace
(withn
set to-1
), because they make the code more readable.Before:
After:
The text was updated successfully, but these errors were encountered: