Skip to content
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

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

Open
cespare opened this issue Sep 26, 2024 · 0 comments

Comments

@cespare
Copy link

cespare commented Sep 26, 2024

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 cespare added the needs-triage Newly filed issue that needs triage label Sep 26, 2024
@dominikh dominikh added new-check and removed needs-triage Newly filed issue that needs triage labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants