Go

Go

By DeepSource

Simplify if statement for single bool judgment GO-R1004

Anti-pattern

if 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.

Examples

Bad practice

if ok := fn(); ok {
    // body
}

Recommended

if fn() {
    // body
}