My personal favorite is that Go does not offer a reentrant lock, i.e. a lock that can be recursively acquired from the same thread or Goroutine (the Go variant of Coroutines or Green Threads). However, without hacks there is no way to build such an implementation by yourself, since threads are not available in Go and Goroutines do not offer an identifier, which would allow you to recognize the same Goroutine you’ve seen before.
At this point, Go is no longer able to see the distinction between the type and the variable
Type or no type, that is the question!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
type handle = int// after go 1.9 type handle int// before go 1.9 funcmain() { var var1 int = 1 var var2 handle = 2 types(var1) types(var2) } functypes(val interface{}) { switch v := val.(type) { caseint: fmt.Println(fmt.Sprintf("I am an int: %d", v)) } switch v := val.(type) { case handle: fmt.Println(fmt.Sprintf("I am an handle: %d", v)) }
Gophers are lazy by nature!
1 2 3 4 5 6 7 8 9 10 11 12
funcmain() { functions := make([]func(), 3) for i := 0; i < 3; i++ { functions[i] = func() { fmt.Println(fmt.Sprintf("iterator value: %d", i)) } } functions[0]() functions[1]() functions[2]() }
Of nil and nothing
1 2 3 4 5 6 7
functest(v bool)error { var e *MyError = nil if v { returnnil } return e }
When e is returned, the *MyError pointer becomes an instance of the interface type error and it’s not nil!