for _, value := range values { go func() {somefn(value)}() } // Every go func sees that same value because the address is
updated
- Must copy variable in a for loop to new value if using in a gofn, address of variable get reused
m := map[string]SomeStruct &m["k"] // Fails to compile
- Cannot take the address of map keys/values: use a pointer when possible
err := somefn() if err != nil { newvar, err := somefn() } // Does not update err in outer scope!
- must declare var newvar string and then use newvar, err = somefn()
go f1(blockingFn()) // blockingFn() not run in a go routine - equivalent to r := blockingFn() go f1(r)
- blockingFn() is run synchronously outside a go routine, and f1 is run in a go routine with the realized argument