Skip to content

Instantly share code, notes, and snippets.

@zainfathoni
Created April 10, 2017 04:04
Show Gist options
  • Save zainfathoni/120953833f52c50aa275ec4d7a7a6dfc to your computer and use it in GitHub Desktop.
Save zainfathoni/120953833f52c50aa275ec4d7a7a6dfc to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) (count map[string]int) {
words := strings.Fields(s)
count = make(map[string]int)
for _, word := range words {
count[word] += 1
}
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