1 min read
Predeclared identifiers
Predeclared identifiers The following identifiers are implicitly declared in the universe block: Types: any bool byte comparable complex64 complex128 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr Constants: true false iota Zero value: nil Functions: append cap close complex copy delete imag len make new panic print println real recover Perhaps confusingly, any of these can be shadowed. That is, you can bind these names to your own variables, constants, functions, etc.
1 min read
Shadowing
The concept of shadowing should be familiar to many readers. But here we see how Go defines it… Declarations and scope … An identifier declared in a block may be redeclared in an inner block. While the identifier of the inner declaration is in scope, it denotes the entity declared by the inner declaration. Notice that shadowing is not limited to variables. You can shadow function names, types, constants, or variables.