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 →
What to know first
- goroutineA goroutine is a lightweight function execution unit managed by the Go runtime that runs concurrently with other program activity.
- slicingSlicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.
Related concepts
- Mapuses · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- 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.
Questions about make
What is make?
make is a Go built-in function that initializes slices, maps, or channels, optionally specifying size or capacity.
Which Manning books explain make?
Go in Action, Second Edition and Learn Go with Pocket-Sized Projects.
What should I know before learning make?
Manning books that teach make usually introduce goroutine and slicing first.
What is the difference between make and map literal?
make is a Go built-in function that initializes slices, maps, or channels, optionally specifying size or capacity. A map literal is Go syntax that creates a map value by specifying its key and element types and optionally initializing entries.
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.

