go-tools
go-tools copied to clipboard
simple: flag superfluous boolean variable declarations in if statements
A potential new check:
Consider
if testValue := someFunc(); testValue {
// do some stuff which doesn't use testValue
}
testValue passes the compiler's check for an unused variable, but is it really used? In my view, the code
if someFunc() {
// do some stuff which doesn't use testValue
}
is unambiguously better.
A quick note that if testValue is used in the block it can be statically replaced with a true (or false, depending).