You can think of a variable as a little labeled box that holds data. In Go, var lets you declare it with a type, and inside a function you can also write it quickly with :=.
go
package main
import "fmt"
func main() {
var language string = "Go"
version := 1.22
isFast := true
fmt.Println(language)
fmt.Println(version)
fmt.Println(isFast)
}var language string = "Go" spells out the type explicitly. version := 1.22 lets the compiler infer the type, and this form only works inside a function.
You should see
Go 1.22 trueInfo
Use a variable if the value might change later. For values that shouldn't change — like an app name or a timeout constant — const is the better choice.