Cover image for Day 5 of #30DaysOfCode | variables, primitive data types, constant and maps in Go

Day 5 of #30DaysOfCode | variables, primitive data types, constant and maps in Go

shubhamsaurav profile image Shubham Saurav ・2 min read

Today is the 5th day of my #30DaysOfCode challenge and I'm so excited to share what I have learnt today.

After I woke up, I performed my daily rituals and then I started learning Go. I practised maps and wrote a simple example that I will be sharing with you today. Then, I dived a bit deeper into variables, primitive data types and constants in #golang. I learnt about scoping, naming convention. I learnt about all the different data types like int8, int16, int32, int64, float32, float64, complex64, complex128, bool, rune. Then, I enjoyed learning about constants, learning about iota, enumerated constants and a lot of other good stuff.

After I had my fun learning all this cool stuff, I promised myself that from tomorrow, I will start reading the Go Programming Language Book that I bought a month ago.

Okay. Now comes the map part.
So, a quick refresher of maps.
(An excerpt from the last post)
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.

Now, let's take a look at the example that I wrote for you today. Take a look at the image below and try to understand the code.

Map in Go | Example

In the image above, there is an example which shows how you can define a map. These are the ways which I would personally use to define a map. Also, if you want to delete a key-value pair from the map, you can just use the delete() function and pass in the map and key in the function as shown in the example above. Also, the delete function works with other data structures too.
Alright! That's all I have for you guys. Thanks for reading the post and don't forget to follow me for more.

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

Posted on Jun 30 by:

shubhamsaurav profile

Shubham Saurav


Writing Restful APIs using JS. Learning to code in Go(Golang)


markdown guide