From the course: Go Essentials: Concurrency, Connectivity, and High-Performance Apps
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Maps - Go Tutorial
From the course: Go Essentials: Concurrency, Connectivity, and High-Performance Apps
Maps
- [Instructor] A map is a data structure where keys points to values. The keys and the values must be of the same type. So here we have a map of stocks. The keys are all strings, and the values are all float64s. We have the Amazon, the Google and the Microsoft stock. And we have to have the last trailing comma. The one right here. And we can use the built-in len to print out the length of the map. And this is going to print three. When we count len, we count the number of keys. If you want to get a value, we are going to use the square brackets. So we're getting the value of the Microsoft stock. If you're looking for a stock that is not in the map or a key that is not in the map, we are going to get the zero value for the values in the map. In this case, the values are float64. So the zero value is the number zero. If you want to know if a value is in the map or not, we can use two values on the left side of the…
Contents
-
-
-
-
Numbers and assignments3m 52s
-
(Locked)
Conditionals2m 35s
-
(Locked)
For loops2m 5s
-
(Locked)
Challenge: FizzBuzz57s
-
(Locked)
Solution: FizzBuzz55s
-
(Locked)
Strings2m 59s
-
(Locked)
Challenge: Even-ended numbers55s
-
(Locked)
Solution: Even-ended numbers53s
-
(Locked)
Slices2m 34s
-
(Locked)
Challenge: Find the maximal value12s
-
(Locked)
Solution: Find the maximal value41s
-
(Locked)
Maps2m 37s
-
(Locked)
Challenge: Maps26s
-
(Locked)
Solution: Maps57s
-
-
-
-
-
-
-
-