What are the performance implications of using pointers versus values in function arguments?

Last updated 20 June 2026

  • Passing by value copies the whole struct: cheap for small types and keeps data on the stack (good locality, no GC work), but expensive for large structs.

  • Passing a pointer copies only an address and allows mutation, but escape analysis may move the value to the heap, adding GC pressure and dereference cost.

  • Pass small values by value and large structs (or ones needing mutation) by pointer. Profile before optimizing.

  • https://learn.appliedgo.net/blog/how-to-do-escape-analysis
  • https://www.boot.dev/blog/golang/pointers-faster-than-values
  • https://github.com/anubhavgh023/go-pointer-vs-value-benchmark
  • https://www.upgrad.com/blog/golang-interview-questions-and-answers/
All Golang interview questions