-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ignore variable declaration if it's the zero value #39
Comments
I agree, and the error returned makes it a bit confusing to understand what the issue is exactly. Especially if someone isn't familiar with relying on a primitive's zero value. |
I hit this as well with:
|
This really would be great to fix. I personally use |
Agreed with @drshriveer. |
I think this is a bug in the linter since both forms should be compiled to the same thing:
If they no not compile to the same thing, this is a bug in the Go compiler. Reporting this as an issue is harmful instead of helping. This just increase the chance that people will disable this linter and missing good reports that should be fixed. |
At work, we are working on updating all our linting, and one of the problems we have hit with wastedassign is that code like this gets flagged:
Now, I know that you should probably write
var isFoo bool
... but it's not technically incorrect, and almost assuredly does not indicate an error, just someone who is used to other languages. It would be great if there were a way to avoid flagging that kind of a line so that we can use it for the other cases when it is much more likely to indicate a bug.The text was updated successfully, but these errors were encountered: