clarkgrubb / hyperpolyglot

hyperpolyglot.org
Other
473 stars 94 forks source link

Go - global variable: no such thing as file scope for variables #49

Closed idubinskiy closed 8 years ago

idubinskiy commented 8 years ago

From https://golang.org/ref/spec#Declarations_and_scope:

The scope of an identifier denoting a constant, type, variable, or function (but not method) declared at top level (outside any function) is the package block.

The only things that are file-scoped are imports.

Capitalization does not affect scope inside the package, it affects whether the identifier is exported (and thus available from outside the package).

clarkgrubb commented 8 years ago

Thanks, it is fixed.