Go memory management
The subject of this section is Go memory management. We are going to begin by stating a fact that you should already be familiar with: Go sacrifices visibility and total control over memory management for the sake of simplicity and the use of the Garbage Collector (GC). Although the GC operation introduces an overhead to the speed of a program, it saves us from having to manually deal with memory, which is a huge advantage and saves us from lots of bugs.
There exist two types of allocations that take place during program execution: dynamic allocations and automatic allocations. Automatic allocations are the allocations whose lifespan can be inferred by the compiler before the program starts its execution. For example, all local variables, the return arguments of functions, and function arguments have a given lifespan, which means that they can be automatically allocated by the compiler. All other allocations are performed dynamically, which also includes data...