News for hackers. Stuff that matters.
Re:Deadcode: Finding unreachable functions in Go by BoppreH on Tuesday January 23, 2024 @02:58PM (#39108884)
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.

Re:Deadcode: Finding unreachable functions in Go by icholy on Tuesday January 23, 2024 @03:14PM (#39109102)
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.