Built-in types
Context
Section titled “Context”Go is a statically typed language. Every variable has a type known at compile time. Here are the main built‑in types.
Boolean type
Section titled “Boolean type”bool–trueorfalse
Numeric types
Section titled “Numeric types”- Signed integers:
int8,int16,int32,int64,int(platform‑dependent: 32 or 64 bits) - Unsigned integers:
uint8,uint16,uint32,uint64,uint,uintptr - Floating point:
float32,float64 - Complex numbers:
complex64(float32+float32),complex128(float64+float64) - Byte and rune:
byte=uint8(ASCII/UTF‑8 byte),rune=int32(Unicode code point)
String type
Section titled “String type”string– immutable sequence of bytes (usually UTF‑8)
Example
Section titled “Example”Declaring variables with explicit types.
Code example
Section titled “Code example”package main
import "fmt"
func main() { var flag bool = true var age int = 30 var price float64 = 19.99 var name string = "Alice" var letter byte = 'A' var symbol rune = 'é'
fmt.Println(flag, age, price, name, letter, symbol)}Output
Section titled “Output”true 30 19.99 Alice 65 233