Types#

Go is statically typed with a small set of primitives, composites (array, slice, map, struct, channel, function, pointer), and structurally satisfied interfaces. Type conversion is always explicit; the compiler never coerces silently.

For literals see Syntax. For methods and interfaces, see OOP.

Primitives#

Primitives

bool, int family, uint family, byte, rune, float32 / float64, complex.

Primitives
Strings

Immutable UTF-8; bytes vs runes; strings.Builder.

Strings
Conversion

Explicit conversions; strconv, fmt.Sprintf.

Conversion

Composites#

Arrays

Fixed-size; [N]T is the type.

Arrays
Slices

Header over a backing array; append, copy, len, cap.

Slices
Maps

Unordered key-value containers; make, delete, comma-ok lookup.

Maps
Structs

Records; named fields; anonymous form.

Structs
Pointers

*T / &x; no pointer arithmetic.

Pointers
Interfaces

Structural satisfaction; any; type assertion / switch.

Interfaces
Channels

chan T; send-only and receive-only directions.

Channels
Functions

Functions as values typed by signature.

Functions

User-defined#

Custom

type Name underlying; nominal branding.

Custom types
Generics

Type parameters (1.18+); cmp.Ordered.

Generics

References#