If you’re reading this post you’re probably searching on Google how to solve this problem: you’re passing a pointer to a
map in a function, and when referencing an item with
*variable, you get that error.
How do I solve it?
The solution is simple: instead of using
Why am I getting this weird error? 🤔
*variable is interpreted by the Go compiler as
*(variable). So what you’re telling the compiler to do is, get the first element in the slice, or the map item with key 0, and dereference that pointer.
This explains the error:
variable in that context is a pointer, not a value, so you cannot get the  item of a pointer to an address, you need to dereference it first to get the value, which is what I think you are trying to do in the first place.
Pssst! Also check my latest YouTube video
I am writing a book on how to create a successful blog as a developer.
It will be released late February.
Signup to my newsletter to get 2/3 free chapters in your inbox in the next few weeks!