Can you declare multiple variables at once in Go?

Kevin Burke picture Kevin Burke · Jan 12, 2014 · Viewed 70.5k times · Source

Is it possible to declare multiple variables at once using Golang?

For example in Python you can type this:

a = b = c = 80

and all values will be 80.

Answer

Kevin Burke picture Kevin Burke · Jan 12, 2014

Yes, you can:

var a, b, c string
a = "foo"
fmt.Println(a)

You can do something sort of similar for inline assignment, but not quite as convenient:

a, b, c := 80, 80, 80