On the updated question: there is actually a difference between long and short declarations, being in that short form allows redeclaration of variables.
From spec:
Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block with the same type, and at least one of the non-blank variables is new. As a consequence, redeclaration can only appear in a multi-variable short declaration. Redeclaration does not introduce a new variable; it just assigns a new value to the original.
field1, offset := nextField(str, 0) field2, offset := nextField(str, offset) // redeclares offset a, a := 1, 2 // illegal: double declaration of a or no new variable if a was declared elsewhere
So I'd say the :=
operator is not pure declare, but more like declare and assign.
Redeclaration in toplevel is not allowed, so neither are short declarations.
Another reason for this might be syntax simplicity. In Go all toplevel forms start with either type
, var
or func
. Short declarations there will ruin all the cuteness.