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

Seems like you're conflating two separate things here. The Go compiler has a DCE pass which prevents unused code from ending up in the binary. The linked blog-post describes a tool for identifying unused code in your codebase. Two completely separate use-cases.



I agree that "changes the generated binary" and "displays information to the user" are separate use cases, but the compiler already does both. There's even a compiler error for unused imports and variables.

Doesn't seem far-fetched to ask for the compiler to warn on unused types/functions too.


It's not that simple. The Go compiler uses a main package as its entry point when compiling a binary. A module can have a many main packages each using different subsets of the library packages.

So there are two choices here:

    1. The Go compiler complains about code which is unused by the current main package.
    2. The Go compiler tries to find/compile all main packages every-time.
Both of these options suck.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: