← Go Programming learning pathGo Programming · Module 2 of 10
Variables, types and functions
Learn Go syntax for values and functions.
📖 Key ideas
- var x int = 5 or short form x := 5.
- Basic types: int, float64, string, bool.
- Functions: func add(a, b int) int { return a + b }.
- Functions can return multiple values: func div(a, b int) (int, error).
- Unused variables and imports are compile errors.
💡 Real-life example: Go is a tidy room rule: anything you bring in (import, variable) must be used, or it complains.
:=Short variable declaration
float6464-bit decimal number
Multiple returnsFunction returns several values
Zero valueDefault value like 0 or ""