Do You Really Understand * and & in Go Programming Language?

Stupidly simple guide you can ever find on the internet.

Nitin Sharma
Geek Culture

--

Photo by Brooke Cagle on Unsplash

When you don’t have a basic guide like this, learning the concept of * and & is literally impossible. However, after reading this post, you will see that it is the most basic concept.

Yes, you will undoubtedly learn the basics there is to know about the * and & operator. And we’ll use the most straightforward example in the Go programming language.

Don’t worry if you’re using a different programming language; the idea is the same, and I believe you can create the code in your preferred language after this.

Excited? Let’s get started.

First and foremost, remember that * and & are opposite of each other. In short, we can transform one into the other.

Yes, please read it again.

Now, let me introduce the & and * operators.

The & operator is used to obtain the address, whereas the * operator is used to obtain the value of an address variable.

Let’s take an example.

Assume we use the Go programming syntax to declare a variable.

a := 1

--

--