← Go Programming learning path
Go Programming · Module 2 of 10

Variables, types and functions

Learn Go syntax for values and functions.

📖 Key ideas

  1. var x int = 5 or short form x := 5.
  2. Basic types: int, float64, string, bool.
  3. Functions: func add(a, b int) int { return a + b }.
  4. Functions can return multiple values: func div(a, b int) (int, error).
  5. 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 ""