Re: [go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-16 Thread Christoph Berger
The linter complains because the second err occurs in a different scope. "if err = f(); err != nil" scopes this err instance to the if block. It re-uses the err from the outer scope, which might not be intended. If you only use either of "err = f(); if err..." or "if err = f(); err..."

Re: [go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-15 Thread Amnon
I would stop using that particular linter. And keep calling your error value err. It is idiomatic. On Monday, 14 August 2023 at 22:36:11 UTC+1 David Finkel wrote: > On Mon, Aug 14, 2023 at 4:54 PM Pablo Caballero wrote: > >> I started working on a Golang project (from my work). The following

Re: [go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-14 Thread David Finkel
On Mon, Aug 14, 2023 at 4:54 PM Pablo Caballero wrote: > I started working on a Golang project (from my work). The following > pattern makes the company configured linter to complain with: > sloppyReassign: re-assignment to `err` can be replaced with `err := > myFunc2()` (gocritic) > > func

[go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-14 Thread Pablo Caballero
I started working on a Golang project (from my work). The following pattern makes the company configured linter to complain with: sloppyReassign: re-assignment to `err` can be replaced with `err := myFunc2()` (gocritic) func myFunc() error { ... blah, err := getBlah() if err != nil { return