Re: [go-nuts] variables name and scope

2018-09-13 Thread thepudds1460
Some people strongly recommend always including `-shadow` when running `go vet`. Using your example: $ go vet -shadow # example .\main.go:20: declaration of "p" shadows declaration at .\main.go:15 --thepudds On Thursday, September 13, 2018 at 9:54:05 AM UTC-4, Jan Mercl wrote: > > On

Re: [go-nuts] variables name and scope

2018-09-13 Thread Jan Mercl
On Thu, Sep 13, 2018 at 3:42 PM wrote: > Why Go accepts to have différents variables with the same name ? Is there any good reasons ? Because Go is a block scoped language like C and others: https://en.wikipedia.org/wiki/Scope_(computer_science)#Block_scope -- -j -- You received this messa

[go-nuts] variables name and scope

2018-09-13 Thread gobluescaster
Hi, Why Go accepts to have différents variables with the same name ? Is there any good reasons ? You can spend a lot of time to find a bug like this: package main import ( "fmt" ) func foo() (c int, d int) { c, d = 1, 2 return } func main() { var p int = 7 fmt.Println("p =", p) //