A naked return omits result expressions and returns the current values of named result parameters. Those parameters begin with their zero values, so returning before assigning an error can silently return nil. section 6.2 section 6.3
The unassigned-error trap
In getCoordinates, `return 0, 0, err` returns nil when `ctx.Err() != nil` because the named err parameter was never assigned. Assigning with `if err = ctx.Err(); err != nil { return }` makes the naked return use the updated error. However, mixing naked returns with returns containing arguments is discouraged here; `if err := ctx.Err(); err != nil { return 0, 0, err }` is the clearer fix. section 6.3
func f(a int) (b int) { #1
b = a
return #2
}
A minimal function shows the required pairing: the named result parameter receives a value, and `return` returns that current value. section 6.2
