feat: add empty slice declaration check#441
feat: add empty slice declaration check#441demoManito wants to merge 2 commits intoquasilyte:masterfrom
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