Local Variable Declarations
Short variable declarations (:=
) should be used if a variable is being set tosome value explicitly.
Bad | Good |
---|---|
|
|
However, there are cases where the default value is clearer when the var
keyword is use. Declaring Empty Slices, for example.
Bad | Good |
---|---|
|
|