Skip to content

Instantly share code, notes, and snippets.

@ryanmr
Created December 28, 2015 20:03
Show Gist options
  • Save ryanmr/8722b9e8cdfda322b490 to your computer and use it in GitHub Desktop.
Save ryanmr/8722b9e8cdfda322b490 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 {
count := map[string]int{}
words := strings.Fields(s)
for _,v := range words {
count[v]++
}
return count
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment