feat(golangci-lint): Disable `govet shadow`.
What
feat(golangci-lint): Disable govet shadow
.
Why
govet's shadow
analyzer never left the "experimental" status, because it
causes many false positives.
It may trigger, for example, when the following pattern is used:
x, err := foo()
if err != nil {
return fmt.Errorf("bar: %w", err)
}
if err := bar(x); err != nil { // <-- govet shadow complains about this line
return fmt.Errorf("bar: %w", err)
}
y, err := baz() // <-- this line triggers the complaint
if err != nil {
return fmt.Errorf("baz: %w", err)
}
The inner err
variable, the one that bar()
assigns to, shadows the outer
err
variable. Because the outer variable is accessed again later (even though
the value is never read), the analyzer thinks that this might be an error.
The complexity of this rule also means that it is very hard to understand why the analyzer is complaining. Personally, I was confused for quite a while because the analyser seemed to "randomly" trigger.