make (built-in)
The built-in Go function that creates a ready-to-use map, slice or channel, such as make(map[string]bool) or make(chan string).
In more detail
Maps and channels must be made before you store into them or send on them. For channels, a second argument sets the buffer size, as in make(chan int, 2). It is unrelated to the GNU make build tool.
Example
seen := make(map[string]bool)Related terms
- map — A Go collection that stores values by key, such as service name to port number, and looks them up quickly.
- channel — A typed pipe in Go that one goroutine sends values into and another receives them from, safely handing data between them.
- buffered channel — A channel created with a capacity, such as make(chan int, 2), that can hold that many values before a send has to wait.
- slice — A flexible, growable view over a list of values of one type, written like []string, and Go's everyday list.
Taught in
- Arrays, Slices, and Maps — Concurrent Systems Programming with Go
- Channels and Synchronization — Concurrent Systems Programming with Go
- The select Statement — Concurrent Systems Programming with Go
- Context Cancellation and Timeouts — Concurrent Systems Programming with Go
- Graceful Shutdown on SIGTERM — Concurrent Systems Programming with Go
- Executing Concurrent Checks — Concurrent Systems Programming with Go