3 ms·
> Why does go need := with the colon? I know it's a declaration, but I haven't figured out the reason for the colon.. Seems weird.. I remember Rob Pike ever sa
by tapirl 7y ago
> Why does go need := with the colon? I know it's a declaration, but I haven't figured out the reason for the colon.. Seems weird..
I remember Rob Pike ever said that one if the reasons of needing := is to avoid declaring many error variables in a function, such as err0, err1, err2, ..., and at the same time we don't need declare then as uninitialized variables.
With :=, they can be all called "err".
Personally, I do prefer to try to avoid using :=.