Sometimes a function, variable, constant, field, or whole package becomes redundant or unnecessary but must be kept for compatibility with existing programs. These should not be used except for compatibility with legacy systems.
true
is implicit in switch
statements CRT-A0015If no tag is given with switch
, it assumes true
.
if
statement for single bool judgment GO-R1004if
statement can be simplified where only a single bool judgment is happening. It is more
idiomatic not to store the result of a function returning a bool and compare that in if
statement's conditional. It is better to skip the initialization expression.
any
instead of interface{}
GO-R3001In Go 1.18+, empty interface (interface {}
) is recommended to be replaced by
any
.
time.Sleep
instead of single case select
SCC-S1037Instead of using a single case in a select
statement that receives results from
time.After
is preferable to simply use time.Sleep
.