The official statement is here 
https://golang.org/doc/faq#unused_variables_and_imports
Compiling methods details are slightly above.

On Sunday, June 26, 2016 at 3:15:15 PM UTC+2, Hotei wrote:
>
>
>
> On Saturday, June 25, 2016 at 3:34:57 PM UTC-4, Val wrote:
>>
>> Hello
>> It seems that this code <https://play.golang.org/p/C5jbcieUS6> doesn't 
>> compile :
>>
>> func main() {
>>     var err error
>>     err = f()
>> }
>>
>> *prog.go:8: err declared and not used*
>>
>>
>> but this one <https://play.golang.org/p/Y5zc4sLbtE> does :
>>
>> func main() {
>>     var err error
>>     g := func() {
>>         err = f()
>>     }
>>     g()
>> }
>>
>> Is the function binding regarded as a "use"?  Or does escape analysis 
>> decide to not check too deep about never-read variables?
>>
>> Whether expected or not, I supposed this compiler behavior won't change, 
>> because of the Go1 compatibility promise.
>>
>> Cheers
>>  Val
>>
>
> Assignment isn't "use".  Doesn't matter if it's a function binding or just 
> x = 3,  if you don't use the left side of your "=" later it's a compile 
> error. 
>

-- 
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.

Reply via email to