3 ms·
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 some
by jstanley 3y ago
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.
- fooster 3y agoHuh? Its a warning, not an error. https://go.dev/play/p/8GazBQv5xAb https://go.dev/play/p/8GazBQv5xAb
- jstanley 3y agoMy mistake!
- packetlost 3y agoIf you're finding you're doing this often, perhaps your functions are too large
- starttoaster 3y agoIf 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.