Description: Personal blog of Dan, a software engineer, and his personal exploits as he stumbles through the games industry
An oft-repeated question on the /r/golang subreddit is “when should I use pointers instead of passing a value?”. This question was asked this evening by /u/TheMadMan001 . Whenever this question gets asked, there are a few positions that people in the comments tend to take, and the most common one I see by a wide margin is that “You should use pointers when you’re dealing with large values, because then Go doesn’t have to copy the value onto the stack”:
One point that was left out from previous posts was the when. If you’re dealing with small or negligible amounts of data then it doesn’t matter too much. The business logic and programmers preferences will drive when a pointer is used or not. However when you have to deal with extremely large variables, in terms of memory size, then passing by pointer will often be required.
/u/germanyhasnosun [ source ]