Go Easy technical 0 views 1 min read

What is the difference between new and make in Go?

Peer-reviewed by HireXTech Technical Panel Updated for 2025/2026 hiring Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of Go conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

new(T) allocates zeroed memory for a value of type T and returns a pointer *T. It works for any type and is rarely used.

make only works for slices, maps and channels. It returns an initialised value of that type (not a pointer) and lets you set length and capacity.

p := new(int)          // *int, points to 0
s := make([]int, 0, 8) // len 0, cap 8
m := make(map[string]int)
ch := make(chan int, 4)

The distinction exists because slices, maps and channels need runtime initialisation before use. A zeroed map is nil, and writing to a nil map panics. new(map[string]int) returns a pointer to a nil map, which is almost never what you want. In practice people skip new for structs and take the address of a composite literal instead, for example &User{}.

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?