logoalt Hacker News

AnimalMuppetlast Tuesday at 6:37 PM3 repliesview on HN

I would be astonished if there isn't an automated tool to check for that at the push of a button. I would be mildly surprised if there isn't a compiler flag to check for it.


Replies

arp242last Tuesday at 6:53 PM

Not a compiler check, but staticcheck is widely used:

    % staticcheck test.go
    test.go:7:2: this value of err is never used (SA4006)
dmitshurlast Tuesday at 7:02 PM

Yeah, as one data point, https://staticcheck.dev/docs/checks/#SA4006 has existed since 2017.

masklinnlast Wednesday at 4:51 AM

There very much is not. There is a compiler error you can’t disable if a variable is completely unused and that is it.