Make

new vs make

July 9, 2024
Golang, New, Make, Pointer

Difference between new and make in Golang # In Go, make and new are built-in functions used for memory allocation. make not only allocates memory but also initializes the data, which is necessary because the data types supported by make (like slices, maps, and channels) require initialization before use. On the other hand, new allocates memory space that is filled with zero values. new allocates a single block of memory, while make may allocate multiple blocks of memory. ...