Skip to content

Instantly share code, notes, and snippets.

@gerep
Created Feb 24, 2015
Embed
What would you like to do?
package main
import (
"strings"
"fmt"
)
func WordCount(s string) map[string]int {
words := strings.Fields(s)
counter := map[string]int{}
for _, word := range words {
counter[word]++
}
return counter
}
func main() {
fmt.Println(WordCount("João e João"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment