Skip to content

Instantly share code, notes, and snippets.

@derencius
Created October 26, 2013 16:28
Show Gist options
  • Save derencius/7171511 to your computer and use it in GitHub Desktop.
Save derencius/7171511 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 {
m := make(map[string]int)
words := strings.Fields(s)
for i := 0; i < len(words); i++ {
m[words[i]] += 1
}
return m
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment