Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Arrays, Slices, and Maps | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 6 of 60

·Go

Arrays, Slices, and Maps

20 minutes

Course progress10%

Arrays, Slices, and Maps

Go has three main collection types: arrays for fixed-size data, slices for flexible sequences, and maps for key-value lookup.

Arrays

Arrays have a fixed length and store values of one type.

var a [3]int
var b = [3]string{"a", , }
"b"
"c"

Slices

Slices are views over arrays with dynamic length and capacity.

s := []int{1, 2, 3}
s = append(s, 4, 5)
sub := s[1:4]

Use len(s) for the number of elements and cap(s) for the current capacity.

Maps

Maps store values by key and are useful for lookup tables.

m := make(map[string]int)
m["alice"] = 42
fmt.Println(m["alice"])

Check whether a key exists using the second boolean result.

if v, ok := m["bob"]; ok {
    fmt.Println("found", v)
}

Info

The order of map iteration is intentionally random. Do not rely on map ordering for deterministic behavior.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonControl Flow: if, switch, for LoopsContinue to lesson 7Structs, Methods, and InterfacesBack to Go Programming Bootcamp curriculum