On Sun, Jan 31, 2021 at 8:04 AM Amnon <amno...@gmail.com> wrote: > I really do not like code like > defer func() { > if cerr := f.Close(); cerr != nil && err == nil { > err = cerr > } > }() .. > If somebody later > changes the function to return unnamed values, this defer will silently fail.
The deferred function literal refers to a named return variable. Changing it to an unnamed one will cause the program to no longer compile. -- 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/CAA40n-U8RLRHfxy6Bu7D8WfU9RzXQneoR%3DWD6mTK8Vz1z3QWkg%40mail.gmail.com.