Skip to content

Instantly share code, notes, and snippets.

@gerep
Created February 24, 2015 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerep/57d9d1655ba106291a4d to your computer and use it in GitHub Desktop.
Save gerep/57d9d1655ba106291a4d to your computer and use it in GitHub Desktop.
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