Go Basics: Maps

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


A map is a very useful data type in Go.

In other language it’s also called dictionary or hash map or associative array.

Here’s how you create a map:

agesMap := make(map[string]int)

You don’t need to set how many items the map will hold.

You can add a new item to the map in this way:

agesMap["flavio"] = 39

You can also initialize the map with values directly using this syntax:

agesMap := map[string]int{"flavio": 39}

You can get the value associated with a key using:

age := agesMap["flavio"]

You can delete an item from the map using the delete() function in this way:

delete(agesMap, "flavio")

Lessons in this unit:

0: Introduction
1: Introduction to Go
2: Your first Go program
3: Compiling and running Go programs
4: Variables and types
5: Operators
6: Strings
7: Arrays
8: Slices
9: ▶︎ Maps
10: Visualize your local Git contributions with Go
11: Use Go to get a list of repositories from GitHub
12: Building a CLI command with Go: cowsay
13: Go CLI tutorial: fortune clone
14: Build a Command Line app with Go: lolcat