Re:Deadcode: Finding unreachable functions in Go
by jstanley on Tuesday January 23, 2024 @02:16PM
(#39108199)
Yes, unreachable code after a "return" in a function is also a compile error. Very frustrating when I just want to nop out part of a function for debugging something else and have to keep fighting the compiler until I find a way that is acceptable.
[ Parent
| on HN ]
Re:Deadcode: Finding unreachable functions in Go
by starttoaster on Tuesday January 23, 2024 @04:08PM
(#39109866)
If you find yourself doing this often, maybe a feature flag pattern using environment variables would end up being a bit nicer looking than throwing a bunch of unreachable code into your code base.
Re:Deadcode: Finding unreachable functions in Go
by fooster on Tuesday January 23, 2024 @02:26PM
(#39108356)
Huh? Its a warning, not an error.
Re:Deadcode: Finding unreachable functions in Go
by jstanley on Tuesday January 23, 2024 @02:45PM
(#39108678)
My mistake!
Re:Deadcode: Finding unreachable functions in Go
by packetlost on Tuesday January 23, 2024 @02:36PM
(#39108535)
If you're finding you're doing this often, perhaps your functions are too large