Skip to content

Instantly share code, notes, and snippets.

@phigasui
Last active October 22, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phigasui/2d2fc31c519c39f8b067c608ac581cd3 to your computer and use it in GitHub Desktop.
Save phigasui/2d2fc31c519c39f8b067c608ac581cd3 to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
words := make(map[string]int)
for _, word := range strings.Fields(s) {
words[word] += 1
}
return words
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment