Skip to content

Instantly share code, notes, and snippets.

@PatrickWalker
Last active May 3, 2020 19:25
Show Gist options
  • Save PatrickWalker/284ebdb42ed8f0e654da741be57c2e47 to your computer and use it in GitHub Desktop.
Save PatrickWalker/284ebdb42ed8f0e654da741be57c2e47 to your computer and use it in GitHub Desktop.
String to Map
func convertStringToMap(in string) map[string]int32 {
rA := []rune(in)
strMap := map[string]int32{}
for _, v := range rA {
if count,ok := strMap[string(v)]; ok {
strMap[string(v)]=count+1
}else{
strMap[string(v)]=1
}
}
return strMap
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment