box-o-sand/oldstuff/gotime/gotour-artifacts/exercise-maps/main.go
2015-06-22 13:15:42 -05:00

20 lines
275 B
Go

package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
counts := make(map[string]int)
words := strings.Fields(s)
for _, word := range words {
counts[word]++
}
return counts
}
func main() {
wc.Test(WordCount)
}