Skip to content

Variables

The variable's type can be inferred from the assigned value.

Declaration: var name type = expression

var s = ""
var s string
var s string = ""

Short declaration: name := expression
Not for package-level variables, only inside a function!

s := ""