21 lines
294 B
Go
21 lines
294 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"golang.org/x/tour/wc"
|
|
)
|
|
|
|
var count map[string]int
|
|
|
|
func WordCount(s string) map[string]int {
|
|
count = make(map[string]int)
|
|
for _, w := range strings.Fields(s) {
|
|
count[w]++
|
|
}
|
|
return count
|
|
}
|
|
|
|
func main() {
|
|
wc.Test(WordCount)
|
|
}
|