bazmurphy / immersive-go-course

An immersive, introductory course to backend software engineering using go.
https://systems.codeyourfuture.io/
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Prep - 03.05 - Go - Stack and Heap Memory #10

Open bazmurphy opened 8 months ago

bazmurphy commented 8 months ago

Read about stack and heap memory - note that the examples here are C++ not Go, but you should be able to follow them. One important difference between these languages is that in Go, you don't need to worry about whether a value lives on the heap or the stack (in fact, Go is allowed to choose where your variable lives, and even move it around) - this means that it's ok to return a pointer to a stack variable in Go. You also don't need to call delete yourself in Go - Go is a garbage collected language so it will delete variables when they're no longer needed.