Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Map type defintion without container

package main

import "fmt"

func main() {
	var grades map[string]int  // defined type but does not create the container for it
	fmt.Printf("%T\n", grades) // map[string]int

	grades["Mary"] = 99
}
map[string]int
panic: assignment to entry in nil map

goroutine 1 [running]:
main.main()
	/home/gabor/work/slides/golang/examples/map-no-container/map_no_container.go:9 +0xba
exit status 2