Skip to content

Instantly share code, notes, and snippets.

@donutloop
Last active July 18, 2017 19:03
Show Gist options
  • Save donutloop/3afc21d79c1d37f43c842414c252ac1f to your computer and use it in GitHub Desktop.
Save donutloop/3afc21d79c1d37f43c842414c252ac1f to your computer and use it in GitHub Desktop.
package maputil
type StringMap struct {
mapping map[string]string
order []string
}
func (sm *StringMap) Set(key, value string) {
sm.mapping[key] = value
sm.order = append(order, key)
}
func (sm *StringMap) Range(f func(string)) {
for _, s := range sm.order {
f(sm.mapping[s])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment