Difference between Value and Pointer variable in Defer in Go
·3 mins
defer
is a useful function to do cleanup, as it will execute in LIFO order before the surrounding function returns. If you don’t know how it works, sometimes the execution result may confuse you.
How it Works and Why Value or Pointer Receiver Matters #
I found an interesting code on Stack Overflow: