Choosing Between Slices of Pointers and Values in Go

2023/08/20
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

The article discusses the decision of whether to use slices of pointers or slices of values in Go programming. The author presents a scenario where a function returns a pointer and the goal is to collect multiple results in a slice. They explain the structural differences between slices of values and slices of pointers, highlighting that slices of pointers add an extra layer of references. Accessing values in a slice of pointers requires dereferencing the pointers using the * operator. The article also mentions the possibility of nil pointers and the need to check for nil before dereferencing. Overall, the article provides insights into the considerations developers should make when choosing between slices of pointers and values in Go programming.