Skip to content

Instantly share code, notes, and snippets.

@v1c77
Created March 13, 2017 08:27
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 v1c77/7898d3d07bf981a252974a43dc992fec to your computer and use it in GitHub Desktop.
Save v1c77/7898d3d07bf981a252974a43dc992fec 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 {
words := strings.Fields(s)
myret := make(map[string]int)
for _, word := range words{
myret[word] += 1
}
return myret
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment