No pointers or pointer-behaving variables used at all. Everything is allocated to the stack.
main's sum variable is "shared down" with add, since it is passed as a parameter. Does not escape to the heap.
add's sum pointer variable is "shared up" with main, since it is returned. Escapes to the heap.
Need to build with the -m and -l flags:
m
is for printing optimization decisions while running.l
is for disabling inlining.
This is done as follows:
cd <case_dir>
go build -gcflags "-m -l" main.go
Understanding Allocations: the Stack and the Heap - GopherCon SG 2019