Skip to content

Instantly share code, notes, and snippets.

@abhishekkh
Created August 20, 2020 01:10
Show Gist options
  • Save abhishekkh/70b5181f97404c4e99518d61e435c09f to your computer and use it in GitHub Desktop.
Save abhishekkh/70b5181f97404c4e99518d61e435c09f to your computer and use it in GitHub Desktop.
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
m:= make(map[string]int)
words:= strings.Fields(s)
for _, word := range words{
elem := m[word]
m[word] = elem + 1
}
return m
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment