Skip to content

Instantly share code, notes, and snippets.

@shibayu36
Last active December 28, 2015 20:59
Show Gist options
  • Save shibayu36/7561300 to your computer and use it in GitHub Desktop.
Save shibayu36/7561300 to your computer and use it in GitHub Desktop.
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
result := make(map[string]int)
for _, word := range strings.Fields(s) {
result[word]++
}
return result
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment