Skip to content

Instantly share code, notes, and snippets.

@TonPC64
Created July 11, 2018 12:40
Show Gist options
  • Save TonPC64/2f6b4997c7147ccd68afa6a712fe11d5 to your computer and use it in GitHub Desktop.
Save TonPC64/2f6b4997c7147ccd68afa6a712fe11d5 to your computer and use it in GitHub Desktop.
package main
import (
"strings"
"golang.org/x/tour/wc"
)
func WordCount(s string) map[string]int {
var strs = make(map[string]int)
for _, str := range strings.Fields(s) {
strs[str]++
}
return strs
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment