mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.73k stars 276 forks source link

Linter rule to enforce empty slice declaration/initialization style #898

Closed denisvmedia closed 11 months ago

denisvmedia commented 11 months ago

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

  1. slice := make([]type)
  2. slice := []type{}

There is also a way of having a non-initialized slice (which should be preferred over the empty slice w/o len and cap in most cases), but this is beyond the scope of this linter

Describe the solution you'd like I'd like to introduce a new linter that will enforce a particular style of these 3 to be used.

Things to take into account:

Describe alternatives you've considered I wasn't able to find any working alternative.

Additional context This can be considered as a follow up feature for #892.

chavacava commented 11 months ago

Hi @denisvmedia, thanks for the proposal. Do you plan to push a PR?

denisvmedia commented 11 months ago

Yes, if you think this might be useful, I can submit a PR.