Go

Go

Made by DeepSource

Omit redundant nil check around loop SCC-S1031

Anti-pattern
Major
Autofix

When using range on nil slices and maps, the loop will never execute, as the length of the iterable will be regarded as zero. This makes an additional nil check around the loop unnecessary.

Bad practice

if s != nil {
    for _, x := range s {
        // ...
    }
}

Recommended

for _, x := range s {
    // ...
}