On Thu, Jul 27, 2023 at 8:04 AM Steve Roth <st...@rothskeller.net> wrote:
>
>  In those cases, what I'd like to write is
>
> if result, err := fn(); err != nil {
>
>     // handle error and bail out
>
> } else {
>
>     // act on result
> }
>
>
> Unfortunately, the compiler gives a warning on that.

As others have pointed out, the compiler does not give such an error.
The error must be coming from some other tool.  If you tell us what
tool that is, perhaps we can fix it.  In general a tool should not
recommend removing the else clause from an if statement with a simple
statement that declares variables if the else clause refers to any of
those variables.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUSEXDinAw_cHEE-SJ8z-feAC2LPwXZESVe03tmFfMYbw%40mail.gmail.com.

Reply via email to