DEV Community

Cover image for Day 4 of #30DaysOfCode | pointers and maps in Go (golang)
Shubham Saurav
Shubham Saurav

Posted on

2 2

Day 4 of #30DaysOfCode | pointers and maps in Go (golang)

Today is Day 4 of my #30DaysOfCode challenge. I started my day with learning maps in Go and then moved to play with pointers a little. So, let's talk about them one by one.

What are Maps?
Maps are a data structure in Go which stores collections of data in key-value pair. If you have worked with programming languages like Python or Swift then you are very familiar with maps. Python and Swift have a data structure called Dictionary which is just like Maps. They are essentially just the same thing but with a different name. They store data in a key-value pair. We will talk more about Maps in the next post, follow me for that.

Pointer example

Now, as promised in the last post, here I am with a simple little example of pointers in #golang. So, let's take a look at the example of a pointer. We use & and * to work with pointers. The & gives us the address of the value in the memory location and * gives us the value of the address that is passed in. Take a look at the example in the image to get a higher-level understanding of pointers and if you have any question then feel free to ask me in the comments below.

BTW, I am sorry for this cryptic explanation but this is how it's work and I don't expect anyone to understand pointers the first time they see it. It's a very confusing topic and it takes lots of practice to get a hang of it. But I promise that I will try to make it simpler next time.
One thing that is interesting to know is that pointer is not a feature that is very specific to Go but it also has its place in programming languages like C and C++.

Alright! that's all for today and I'll see you in the next post.

Connect With Me:
Youtube: ShubhamSauravYT.
Twitter: @hiShubhamSaurav
Instagram: @hiShubhamSaurav
Facebook: @hiShubhamSaurav

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay