-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: add empty slice declaration check #441
base: master
Are you sure you want to change the base?
Conversation
@quasilyte PTAL |
050dbc4
to
fe144c7
Compare
I think the issue is that nil slice and empty slice are different things and some APIs may require one or another. |
Yes, but I need to detect some empty slices that are not necessary and if not, nolint skips |
In most cases, empty slices, simply stating that a nil slice is sufficient |
Sounds like a too opinionated. I understand you intention but this is not 1:1 replacement. However, |
Just like in this PR, most empty slices are meaningless, either defined as I think these situations need to be reported when needed. |
I agree but blindly replacing it sounds wrong to me, see https://go.dev/play/p/tVN7c2t8kMc To clarify again: I'm not saying "this a wrong", I'm saying "this check is not for everyone". Consider to use gocritic (1) or golangci-lint (2) where you can specify this rule |
hello @cristaloleg , go-critic/go-critic#1337 Do you mean to add it here? |
Nah, I meant to add it as a personal ruleguard rule. |
https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices