Last active
August 29, 2015 14:13
-
-
Save kumikoda/8c0a389e956ba3866a76 to your computer and use it in GitHub Desktop.
Golang tutorial maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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