Go is a statically typed language: every variable’s type is fixed at compile time and checked before the program runs. Types include the numeric families (int, float64, etc.), bool, string, and composite types built from them (arrays, slices, maps, structs). Go performs no implicit conversion between numeric types — mixing an int and a float64 in an expression is a compile error, not a silent truncation.
Declaring variables: var and :=
Go has two ways to declare a variable. var name Type = value is explicit and works anywhere, including package level. Inside a function, the short form name := value declares and infers the type from the value in one step, and is by far the more common style in idiomatic Go code.
var name string = "Gopher" // explicit type
var age = 12 // type inferred as int
count := 0 // short form, only inside functions
price, ok := 19.99, true // multiple short declarations
var total int // zero value: 0
var label string // zero value: "" (empty string)
var found bool // zero value: false
var ptr *int // zero value: nilThe basic types
Go's built-in types split into families: signed and unsigned integers of fixed widths (int8 through int64, uint8 through uint64, plus the platform-sized int and uint), floating point (float32, float64), bool, string (an immutable sequence of bytes, conventionally UTF-8), and byte (an alias for uint8) and rune (an alias for int32, representing a single Unicode code point). Most everyday code just uses int, float64, string, and bool and only reaches for a specific width when memory layout or interop requires it.
Zero values, not garbage
A variable declared with var and no initializer is never left with unpredictable memory contents the way an uninitialized variable in C is. Go always initializes it to that type's zero value: 0 for numeric types, "" for strings, false for booleans, and nil for pointers, slices, maps, channels, functions, and interfaces. This is a deliberate safety guarantee baked into the language specification, and it means a freshly declared struct is always in a valid, predictable state before any field is explicitly set.