Variables
Declare with var or the short form :=. Go is statically typed and unused variables are errors. Zero values are 0, "" and false.
Example
package main
import "fmt"
func main() {
var a int
var b = "hi"
c := 3.5
var d, e = 1, 2
fmt.Println(a, b, c, d, e)
}Result
0 hi 3.5 1 2
Exercise
Short declaration.
x 5
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.