Open dominikh opened 5 years ago
Sadly, my related proposal https://github.com/golang/go/issues/21263 was declined. 😉
@dominikh
Either enable the check (optionally with some improvements) or remove it.
I'd say: remove it.
Using x++
(but, alas, not ++x
) in Go is a bit confusing in the beginning if you've worked with ++x
and --x
in other languages before because it's a statement in Go instead of an expression as in other languages (not to mention the difference between ++x
and x++
and what version Go actually compiles to). So you have to re-learn its use anyway in Go and probably end up with x += 1
so that recommending the use x++
wouldn't actually help.
Hence leave it to the programmer and don't interfere with a linter recommendation.
CheckIncDec flags
x += 1
and recommends usingx++
instead. The check exists, but isn't made available, not even as an optional check. We haven't enabled it so far because it can produce unhelpful warnings for code like the following:Either enable the check (optionally with some improvements) or remove it.