Go

Go

Made by DeepSource

Redundant deferring of calls GO-W4012

Anti-pattern
Minor
Autofix

deferring calls just before a return statement is redundant and can be safely removed.

Bad practice

func foo() {
    bar()
    defer baz() // defer baz() is placed just before the return
    return
}

Recommended

func foo() {
    bar()
    baz()
    return
}