Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can use the _ signifier to mark imports as optional during development: use

    import _ "net"
Make sure you don't check such lines of code in to your repo, because there is a concrete benefit to having the language enforce this import strictness.

But the person who would check in code with unused _ imports, would probably abuse a hypothetical "allow unused imports" flag in production. Go is probably not for that person.



Most Go developers just use goimports. So really this "unused import" warning is a "you forgot to push the magic fix-it button." (Why didn't it push it for me?)

Or more to the point, if Go can figure out imports, why require them to be explicit at all?




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

Search: