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

Complain about range len(someSlice) #27

Closed
mitar opened this issue Sep 6, 2024 · 1 comment · Fixed by #28
Closed

Complain about range len(someSlice) #27

mitar opened this issue Sep 6, 2024 · 1 comment · Fixed by #28
Assignees
Labels
enhancement New feature or request

Comments

@mitar
Copy link

mitar commented Sep 6, 2024

Is your feature request related to a problem? Please describe.

So I found that in our codebase we had loops like:

for i := 0; i < len(someSlice); i++ { ... }

And that now I replace this with:

for i := range len(someSlice) { ... }

But in fact this could be further simplified to:

for i := range someSlice { ... }

Describe the solution you'd like

That this linter also complains if you are doing int range over slice length instead of just range over the slice itself.

Describe alternatives you've considered

Manual find of range len( string in our codebase.

@mitar
Copy link
Author

mitar commented Sep 9, 2024

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants