Make
make is a Go built-in function that initializes slices, maps, or channels, optionally specifying size or capacity.
Go in Action, Second Edition
make is a Go built-in function that allocates and initializes slices, maps, or channels with a specified type and size parameters.
- How it is used
- Initializes Go slices, maps, and channels for collection storage or communication between goroutines.
- How deep it goes
- Explains slice backing arrays and capacity constraints, map initialization, and channel creation through usage examples.
- Examples
- Uses preallocated integer slices, integer-to-string maps, and channels for fetching and saving feed articles.
- What you can do after
- Apply make to initialize collections and create channels, choosing slice capacity for anticipated growth and avoiding nil-map assignment panics.
Learn Go with Pocket-Sized Projects
make is a Go built-in function that initializes slices, maps, or channels with specified size-related parameters.
- How it is used
- Initializes maps and slices while implementing book counting and repeated-book collection.
- How deep it goes
- Explains allocation, map size hints, and slice length versus capacity, but defers deeper slice internals.
- Examples
- Demonstrates map counting, explicit map sizing, indexed slices, reserved capacity, and appending repeated books.
- What you can do after
- Build it from scratch by choosing map size hints and slice length or capacity for collection-based functions.
Read how Learn Go with Pocket-Sized Projects explains make →
Related concepts
- Mapuses · A map is an associative data structure that stores key-value pairs and uses keys to identify and access associated values.
- channelproduces · A channel is a typed Go communication and synchronization mechanism through which goroutines send and receive values.
- capacityconfigured by · Capacity is the maximum amount of a specified resource, workload, or contents that a system, structure, or process can accommodate under given constraints.
- slicingproduces · Slicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.
- zero valueproduces · A zero value is the default, type-dependent value assigned when a variable, field, or newly allocated value has no explicit initial value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

