box-o-sand/gotime/src/meatballhat.com/gotour-artifacts/exercise-maps/main.go

20 lines
305 B
Go
Raw Normal View History

2012-08-26 02:18:48 +00:00
package main
import (
"strings"
"code.google.com/p/go-tour/wc"
)
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)
}