OneBug This week's bugs
Spot the bug Go
1
package main
2
 
3
import "fmt"
4
 
5
func wordFreq(words []string) map[string]int {
6
	var freq map[string]int
7
	for _, w := range words {
8
		freq[w]++
9
	}
10
	return freq
11
}
12
 
13
func main() {
14
	fmt.Println(wordFreq([]string{"go", "go", "rust"}))  // panic: assignment to entry in nil map
15
}

Read the full write-up for this bug (spoilers)