|
|
|
|
|
by NateDad
4258 days ago
|
|
Yup, this is why you don't need err1 err2 err3 err4... (I've had to do similar things in C# before). Also, := does shadow in a sub-scope. The difference between shadowing and simply assigning in the same scope is negligible (i.e. either way you can't get at the old value). err := foo()
if err != nil {
err := bar() // err shadowed here
}
f, err := baz() // err assigned here
What would be the difference between shadowing and assigning on that last line? You can't unshadow without leaving scope, at which point the value you were shadowing also leaves scope. |
|