in https://play.golang.org/p/5P5vcebYkGj you're shadowing s by creating a new variable via :=
this is a common go interview question :) On Sat, Feb 23, 2019 at 9:34 PM <gnir...@gmail.com> wrote: > > Hello, > > It's likely that I'm misinterpreting the language spec. It's also easy to > circumvent by assigning the offending variable to _. Even if this turns out > to be complying with the spec, thought this post may help anyone else looking > up this forum for answers. > > https://play.golang.org/p/5P5vcebYkGj reports an unused error for a package > variable initialized inside init() even though it's used elsewhere. In this > case doSomething() has 2 return values, one of which is the package variable > while the other is local. > > https://play.golang.org/p/DBXdNOHAA2Z does not report an error for a package > variable initialized inside init(). In this case doSomething() has a single > return value. > > https://play.golang.org/p/pdz2mMnQ_EZ similarly does not report an error for > 2 package variables initialized inside init(). In this case doSomething() has > 2 return values as well. > > Thanks > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.