Skip to content

Instantly share code, notes, and snippets.

@kumarsoumya
Created July 31, 2018 22:10
Show Gist options
  • Save kumarsoumya/ba79e8222a6b2c9fca895cb966103c68 to your computer and use it in GitHub Desktop.
Save kumarsoumya/ba79e8222a6b2c9fca895cb966103c68 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 {
words := strings.Fields(s)
wordCount := make(map[string]int)
for _, word := range words {
wordCount[word] = wordCount[word] + 1
}
return wordCount
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment