Variables and Types
Declare with var or the short form := inside functions. Types include int, float64, string and bool. Unassigned variables get a zero value (0, "", false). Go refuses unused variables and imports.
Example
var name string = "Ada"
age := 21
price := 19.99
var ok bool
const Max = 100
fmt.Println(name, age, price, ok, Max)
fmt.Printf("%T %T\n", age, price)Result
Ada 21 19.99 false 100 int float64
Exercise
Short declaration operator.
x 5
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.