Maps are perfect for counting occurrences:
words := []string{"apple", "banana", "apple", "cherry", "apple"}
count := make(map[string]int)
for _, word := range words {
count[word]++ // zero value is 0, so this works
}
fmt.Println(count["apple"]) // 3
Since missing keys return the zero value ( for int), you can increment directly without checking if the key exists first.