You need to make sure all resources allocated in a function are released prior to returning from the function (one common way is via defer blocks), or that the caller will eventually release any resources returned to it. As you said, there is no automatic garbage collection happening.