no new variables on left side of :=
Remove the colon :
from the second statement as you are assigning a new value to existing variable.
myArray = [...]int{11,12,14}
colon :
is used when you perform the short declaration and assignment for the first time as you are doing in your first statement i.e. myArray :=[...]int{12,14,26}
.
There are two types of assignment operators in go :=
and =
. They are semantically equivalent (with respect to assignment) but the first one is also a "short variable declaration" ( http://golang.org/ref/spec#Short_variable_declarations ) which means that in the left we need to have at least a new variable declaration for it to be correct.
You can change the second to a simple assignment statement :=
-> =
or you can use a new variable if that's ok with your algorithm.