Richard Bucker

golang - are short declarations positional

Posted at — Apr 16, 2015

Short variable declarations are a mainstay of the Go language and it looks something like:

a, b := 1, 2a, c := 3, 4d, a := 5, 6
Notice that in line 2 and 3 variables ‘c’ and ’d’ are declared and assigned; and ‘a’ has it’s value reassigned.

So the question: Is there an idiomatic position, from the go authors, as to whether or not error should be the last field in a function declaration?
func() (int, error)func() (error, int)
All of the sample code I’ve read has the error declared in the second or last position and the user data in the first of left-most positions.