Last active
March 26, 2020 22:30
-
-
Save heathhenley/7a4e1c7787cfdc0798e824346f6fdf3e to your computer and use it in GitHub Desktop.
golang_tutorial_map_example
This file contains 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 ( | |
"golang.org/x/tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
word_map := make(map[string]int) | |
for _, word := range strings.Fields(s) { | |
word_map[word]++ | |
} | |
return word_map | |
} | |
func main() { | |
wc.Test(WordCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment