Programming Languages
Go
Subjective
Oct 04, 2025
Explain maps in Go.
Detailed Explanation
Maps in Go:
• Key-value data structure (hash table)
• Reference type, zero value is nil
• Keys must be comparable types
• Dynamic size
• Not thread-safe
Example:
// Declaration
var m map[string]int
m = make(map[string]int)
// Literal
m := map[string]int{
"apple": 5,
"banana": 3,
}
// Operations
m["orange"] = 7
value, ok := m["apple"]
delete(m, "banana")
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts