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. However, you _shouldn't_.
```golang
func main() {
var s = []int{1, 2, 3}
fmt.Println(len(s))
}
func len(any) int { // Never, ever do this!!!
return -1000
}
When Go 1.21 is released, presumably in August, this list will be extended to include three new functions: min
, max
, and clear
.
Quotes from The Go Programming Language Specification Version of December 15, 2022