Go Memory Allocation: var, new, and make Explained
In Go, the keywords var, new, and make are used for memory allocation, but they serve different purposes. Understanding their behavior is essential for writing correct and efficient Go code.
Using var with different types
When you declare a variable with var, the type determines whether it gets a zero value or nil.
var ptr *int
fmt.Println(ptr) ...
Posted on Tue, 18 Aug 2026 16:54:32 +0000 by daria