I get warning in goland when I created same name of package level variable - I created several go files in one directory where each file has a same named variable - but it can still run successfully. so, is this allowed in go to use same variable in different files that are under same directory? I think this is definately not a good practice but wondering what’s actual consequence.
$ for f in $(\ls *.go); do printf "# File: %s\n" $f; cat $f; done
# File: bar.go
package duplicate
var foo int
# File: foo.go
package duplicate
var foo int
$ go build
# _/tmp/tmp.jpv0KFpdQj
./foo.go:3:5: foo redeclared in this block
previous declaration at ./bar.go:3:5
$ echo $?
2
So how do you build? Whats the content of the files?