Skip to content

Instantly share code, notes, and snippets.

@ripiuk
Created January 30, 2019 09:09
Show Gist options
  • Save ripiuk/020b4b1de749ba2e84d7f8d0fe0ef23a to your computer and use it in GitHub Desktop.
Save ripiuk/020b4b1de749ba2e84d7f8d0fe0ef23a to your computer and use it in GitHub Desktop.
go tour exercise (moretypes/23)
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
count := make(map[string]int)
words := strings.Fields(s)
for _, word := range words {
count[word]++
}
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