Skip to content

Instantly share code, notes, and snippets.

@briandowns
Last active August 29, 2015 14:08
Show Gist options
  • Save briandowns/18d323daab86bed3039a to your computer and use it in GitHub Desktop.
Save briandowns/18d323daab86bed3039a to your computer and use it in GitHub Desktop.
Word Count
package main
import (
"fmt"
"strings"
)
func main() {
str := "olly olly in come free"
data := make(map[string]int)
for _, s := range strings.Split(str, " ") {
if _, ok := data[s]; ok {
data[s]++
continue
}
data[s]++
}
fmt.Println(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment