How to Declare Multiple Variables in Go

Declare multiple Go variables on one line using comma-separated names or a block declaration for mixed types.

Declare multiple variables of the same type on a single line by listing their names separated by commas before the type.

var x, y, z int

For variables with different types or initial values, use a block declaration with parentheses.

var (
	name string
	age  int
	done bool
)

You can also declare and initialize them simultaneously.

x, y, z := 1, 2, 3

Or with explicit types and values:

var (
	name string = "Alice"
	age  int    = 30
)