Yeah, insisting on things like a variable being used will result in people using work arounds. It won’t result in people not doing it.
Then, because people trust the language to police this rule, the work-arounds and debug code will get committed.
func main() {
test := true
}
Oops, golang doesn’t like that.
func main() {
test := true
_ = test
}
Perfectly cromulent code.
If they really wanted to avoid people having unused variables, they should have used a naming convention. Any variable not prefixed by “_” or “_debug_” or whatever has to be used, for example. Then block any code being checked in that still contains those markers.