OK. If you take the https://play.golang.org/p/L8z2Q_F_fi3
and change the line 18 from func foo() (err error) { to func foo() error { The code will continue to compile. But it will stop working (i.e. the error from f.Close will not be returned by foo). Unfortunately this is not a contrived example. The earlier link I posted https://github.com/blevesearch/bleve/blob/369ad22b9fefdadb42b9367193ef7a73b9e5f4ff/search/searcher/search_regexp.go#L54 is bleve, a search engine with 7.4K stars on Github which is widely used in production. The moral of the story is: don't write convoluted code which is hard to understand, and which is prone to silent breakages. On Sunday, 31 January 2021 at 16:51:12 UTC Jan Mercl wrote: > On Sun, Jan 31, 2021 at 5:24 PM Amnon <amn...@gmail.com> wrote: > > > https://play.golang.org/p/jnRn4Bv98xS > > > > See the example on the Go Playground. > > > > Jan, someone can explain to me why it will no longer compile? > > That's not an example of what I wrote: "Changing it to an unnamed one > will cause the program to no longer compile." > > Your example is "making the return variable unnamed and declaring a > new, different variable of the same name in the same scope". > -- 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/b018b5b5-4361-4086-8704-01ee08b02e35n%40googlegroups.com.