Hacker News new | ask | show | jobs
by suessflorian 1099 days 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
3 comments

You 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
Builtins aren't keywords.
A function is not a keyword.