Skip to content

Instantly share code, notes, and snippets.

@Raghav2211
Created September 7, 2020 08:31
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 Raghav2211/7dce7bddfacb3ffde355608f37e1ce73 to your computer and use it in GitHub Desktop.
Save Raghav2211/7dce7bddfacb3ffde355608f37e1ce73 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 {
splitInput := strings.Split(s," ")
wordCount := make(map[string]int)
for _ , r := range splitInput {
wordCount[r] = wordCount[r]+1
}
return wordCount
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment