3 ms·
Nice - but hang on a second, I thought you cannot shadow language keywords in Go. So projects bumping to 1.21 in the future should be aware that you will run in
by suessflorian 3y ago
Nice - but hang on a second, I thought you cannot shadow language keywords in Go. So projects bumping to 1.21 in the future should be aware that you will run into compile time errors all of a sudden… doesn’t that actually break the compatibility promise?
max := something()
https://go.dev/doc/go1compat https://go.dev/doc/go1compat
- tedunangst 3y agoBuiltins aren't keywords.
- medellin 3y agoA function is not a keyword.
- oefrha 3y agoYou can shadow any builtin function. package main func main() { arr := make([]int, 0, 10) make := 1 arr = append(arr, make) len := func(arr []int) int { return -1 } println(len(arr)) // Output: -1 } https://go.dev/play/p/pG3Qi8G4dS5 https://go.dev/play/p/pG3Qi8G4dS5