Hacker News new | past | comments | ask | show | jobs | submit login

> You can fork it and set it to RemoveOnly.

This seems like it removes half the value of the tool, though. I can comment out a line of code, compile and test the program. But if I uncomment that line, I'm now missing an import.

edit- how does a tool like this sound?

* If it sees an unused import, it comments it out

* If it sees an import is needed, and there's a commented-out import which would fit, it uncomments it.

* It can run in a "check for commented-out imports" mode, so that commit hooks can reject such a state.

I guess (making some assumptions about go's import semantics) this would avoid the ambiguous name problem; it would mean you avoid having to edit both the import and the usage at the same time; and it makes it easy to tell if a file should be cleaned up.

Maybe it would cause issues if you're trying to choose between two libraries which both provide the same symbols?

Well, that's the point! If you don't want inaccurate imports and just want to remove unused imports you can comment that line. A better option would be to use an additional argument to that function (removeOnly bool) and perhaps a flag on the executable so that you can choose when to use the removeOnly option. Either way the automatic imports and even the removeOnly option alone requires various trade-offs(i.e. accuracy, compiler speed etc) and this is another reason why such features are better developed in stand alone/external tools.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact