Skip to content

Instantly share code, notes, and snippets.

@heathhenley
Last active March 26, 2020 22:30
Show Gist options
  • Save heathhenley/7a4e1c7787cfdc0798e824346f6fdf3e to your computer and use it in GitHub Desktop.
Save heathhenley/7a4e1c7787cfdc0798e824346f6fdf3e to your computer and use it in GitHub Desktop.
golang_tutorial_map_example
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
word_map := make(map[string]int)
for _, word := range strings.Fields(s) {
word_map[word]++
}
return word_map
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment