Skip to content

Instantly share code, notes, and snippets.

@ggirtsou
Created October 25, 2016 15:58
Show Gist options
  • Save ggirtsou/09425146103d940011190c4471aa2f53 to your computer and use it in GitHub Desktop.
Save ggirtsou/09425146103d940011190c4471aa2f53 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 {
var m = map[string]int{}
words := strings.Fields(s)
for _, word := range words {
m[word]++
}
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