Relative Content

Tag Archive for gopointers

Returning a pointer to a local variable in Go

I’m new to Go (I normally use C/C++), and I saw the following piece of code in my codebase at work, and I’m not sure if it’s a bug. It would be in C/C++ because it’s returning a pointer to a local variable created within get_ptr which goes out of scope at the end of the function, so the behavior would be undefined.