Unsigned integer large enough to hold any pointer’s bit pattern.Used for low-level programming and unsafe operations.
var a uint8 = 255var b uint16 = 65535var c uint32 = 4294967295var d uint64 = 18446744073709551615var e uint = 42// uintptr for pointer arithmeticvar ptr uintptr = uintptr(unsafe.Pointer(&e))
int and uint are distinct types from their sized variants (e.g., int is not an alias for int32 or int64).
var f32 float32 = 3.14159265var f64 float64 = 3.141592653589793// Scientific notationvar big = 1.23e9 // 1.23 × 10^9var small = 1.23e-9 // 1.23 × 10^-9// Special valuesvar inf = math.Inf(1) // Positive infinityvar nan = math.NaN() // Not a number
Use float64 by default unless you have a specific reason to use float32. Most math operations return float64.
Equivalent to interface{} in all ways. Can hold values of any type.
var a any = 42var b any = "hello"var c any = []int{1, 2, 3}// Type assertionif str, ok := a.(string); ok { fmt.Println("String:", str)}// Type switchswitch v := a.(type) {case int: fmt.Println("Integer:", v)case string: fmt.Println("String:", v)default: fmt.Println("Unknown type")}
These types appear in the builtin package for documentation purposes only.
Type
Stand-in for any Go type in function signatures. Represents the same type within a function invocation.Not a real type; used only in documentation.
Type1
Stand-in for a second distinct Go type in function signatures.Not a real type; used only in documentation.
TypeOrExpr
Stand-in for either a Go type or an expression in function signatures.Not a real type; used only in documentation.
IntegerType
Stand-in for any integer type: int, uint, int8, int16, int32, int64, uint8, uint16, uint32, uint64, uintptr.Not a real type; used only in documentation.
FloatType
Stand-in for either float32 or float64.Not a real type; used only in documentation.
ComplexType
Stand-in for either complex64 or complex128.Not a real type; used only in documentation.