Go keeps its language small by providing a fixed set of pre-declared built-in functions that live in no package and cannot be imported or shadowed sensibly. They handle allocation, slicing, maps, channels, and panics. This tool is a searchable reference covering each built-in’s signature, the types it accepts, and exactly when it panics.
How it works
Built-ins are part of the language spec, not the standard library, so they need
no import. Several are generic over many types (len, cap, append), while
others are restricted to specific reference types (make, close, delete).
The reference groups them by purpose:
- Allocation —
make(slices/maps/channels),new(any type, returns a pointer). - Slices —
len,cap,append,copy,clear. - Maps —
len,delete,clear. - Channels —
make,len,cap,close. - Ordered values —
min,max(Go 1.21+). - Errors/flow —
panic,recover. - Complex numbers —
complex,real,imag.
Worked example
s := make([]int, 0, 4) // len 0, cap 4
s = append(s, 1, 2, 3) // assign back: append may reallocate
n := copy(dst, s) // n = number of elements copied (min of lengths)
delete(m, "key") // no-op if key absent, never panics
close(ch) // panics if ch is nil or already closed
The key habit is reassigning the result of append, because it may return a
slice backed by a freshly allocated array.
Notes
lenandcapare the only built-ins whose results can be constant when the argument is an array or array pointer with no side effects.deleteon a missing key is a safe no-op; it never panics.panicunwinds the stack running deferred functions; arecoverinside one of those deferred functions stops the unwinding and returns the panic value.min,max, andclearrequire Go 1.21 or newer.