rydmyw
Last Updated: February 25, 2016
·
253
· lukasz-madon
B2bc42f69510d6a1d2c9cde1c2214d24

Count Words in Go

import ( "strings" ) 

func WordCount(s string) map[string]int { 
    words := strings.Fields(s) 
    m := make(map[string]int) 
    for _, word := range words { 
        m[word] += 1 
    } 
    return m 
}
Say Thanks
Respond