點燈坊

失くすものさえない今が強くなるチャンスよ

Multiple Variables Declaration

Sam Xiao's Avatar 2022-03-12

Multiple variables can be declared using a single statement.

Version

Go 1.17.7

package main

import "fmt"

func main() {
    msg, name := "Hello", "World"
    fmt.Println(msg, name)
}
  • Hello is for msg variable, World is for name variable respectively
  • Type is inferred automatically by Type Inference

mutiple000

Conclusion

  • It is so concise to declare multiple variables in one line