0PricingLogin
Go Academy · Lesson

Maps: Key-Value Stores

Creating, reading, writing and deleting map entries

What Is a Map?

A map in Go is an unordered collection of key-value pairs. Keys must be a comparable type (strings, ints, etc.). Maps are reference types backed by a hash table.

Creating Maps

Use a literal or make:

package main
import "fmt"

func main() {
    ages  := map[string]int{"Alice": 30, "Bob": 25}
    cache := make(map[string]string)
    fmt.Println(ages, cache)
}

All lessons in this course

  1. Arrays: Fixed-Length Collections
  2. Slices: Dynamic Lists
  3. Maps: Key-Value Stores
  4. Iterating Collections with range
← Back to Go Academy