Maps (Key-Value Storage, Comma-Ok Idiom & Iteration) - Go Tutorial for Beginners #10
11views
009:50
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Master Go's built-in hash table - Maps! Learn to store and retrieve data with lightning-fast key-value lookups.
In this lesson, you will learn:
✓ Creating and initializing maps
✓ Accessing, adding, and updating values
✓ The comma-ok idiom for safe key access
✓ Why zero value ambiguity matters
✓ Deleting keys and iterating over maps
✓ nil vs empty maps - a critical distinction
✓ Maps with struct values
⏱️ Timestamps:
0:00 - Introduction
0:24 - Map Basics (Create, Access, Add, Update)
2:12 - Comma-Ok Idiom (Safe Access)
4:21 - Delete and Iterate
6:11 - Make and Struct Values
8:25 - Recap
8:55 - End
💻 Source Code: https://github.com/GoCelesteAI/go_maps
📝 Quick Reference:
// Create a map
ages := map[string]int{
"Alice": 25,
"Bob": 30,
}
// Comma-ok idiom
age, exists := ages["Carol"]
if exists {
fmt.Println(age)
}
// Delete and iterate
delete(ages, "Bob")
for name, age := range ages {
fmt.Printf("%s: %d\n", name, age)
}
📺 Full Playlist: Go Tutorial for Beginners
📺 Previous: Lesson 9 - Arrays & Slices
📺 Next: Lesson 11 - Functions
👍 Like and Subscribe for more Go tutorials!
#Go #Golang #Programming #Tutorial #Maps #HashMap #LearnToCode #CodingForBeginners