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
Make "unused imports" a warning (via flag) #3778
Labels
Comments
Or for import X, write at the top level var _ X.SomethingInX // Delete before committing. http://golang.org/doc/go_faq.html#unused_variables_and_imports Status changed to WorkingAsIntended. |
In case someone reads this in the hope of finding a practical and reasonable way I suggest replacing the two yyerrorl() in question with warnl(). --- a/src/cmd/gc/lex.c Mon Jun 25 08:54:36 2012 -0700 +++ b/src/cmd/gc/lex.c Tue Jun 26 09:03:15 2012 +0200 @@ -2187,7 +2187,7 @@ // errors if a conflicting top-level name is // introduced by a different file. if(!s->def->used && !nsyntaxerrors) - yyerrorl(s->def->lineno, "imported and not used: \"%Z\"", s->def->pkg->path); + warnl(s->def->lineno, "[W] imported and not used: \"%Z\"", s->def->pkg->path); s->def = N; continue; } @@ -2195,7 +2195,7 @@ // throw away top-level name left over // from previous import . "x" if(s->def->pack != N && !s->def->pack->used && !nsyntaxerrors) { - yyerrorl(s->def->pack->lineno, "imported and not used: \"%Z\"", s->def->pack->pkg->path); + warnl(s->def->pack->lineno, "[W] imported and not used: \"%Z\"", s->def->pack->pkg->path); s->def->pack->used = 1; } s->def = N; |
I agree, it really decreases my productivity when doing development. Can we also do warning for unused variable? I think warnings would be more appropriate for these unused variables. Please consider making this error a warning instead (yyerrorl -> warnl), or switchable via flag: -dev, -devmode or something. |
http://tip.golang.org/doc/effective_go.html#blank Labels changed: added restrict-addissuecomment-commit. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: