Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Created April 14, 2016 08:02
Show Gist options
  • Save kkabdol/be6a6e8c2d4c96c7af975387b696d141 to your computer and use it in GitHub Desktop.
Save kkabdol/be6a6e8c2d4c96c7af975387b696d141 to your computer and use it in GitHub Desktop.
go langauge exersice
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
ret := map[string]int{}
split := strings.Split(s, " ")
for _, ss := range split {
_, ok := ret[ss]
if ok == true {
ret[ss]++
} else {
ret[ss] = 1
}
}
return ret
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment