Skip to content

Instantly share code, notes, and snippets.

@kumikoda
Last active August 29, 2015 14:13
Show Gist options
  • Save kumikoda/8c0a389e956ba3866a76 to your computer and use it in GitHub Desktop.
Save kumikoda/8c0a389e956ba3866a76 to your computer and use it in GitHub Desktop.
Golang tutorial maps
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
"fmt"
)
func WordCount(s string) map[string]int {
result := make(map[string]int)
for _,key := range(strings.Fields(s)) {
fmt.Println(key)
result[key]++
}
return result
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment