Go provides two different built-in functions for memory allocation: make() and new(). Understanding when to use each is essential for writing idiomatic Go code. The make() function is used exclusively for slices, maps, and channels. It allocates memory, initializes the internal data structure, and returns a ready-to-use value, not a pointer.
The new() function, by contrast, allocates memory for a type, initializes it to its zero value, and returns a pointer to it. It works with any type but is most commonly used for creating pointers to structs. Use make() for slices, maps, and channels; use new() for pointers to zero-initialized values when you specifically need a pointer rather than an initialized collection.