Skip to content

Instantly share code, notes, and snippets.

@giulioungaretti
Created November 25, 2014 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giulioungaretti/3a741aafdf710e54f266 to your computer and use it in GitHub Desktop.
Save giulioungaretti/3a741aafdf710e54f266 to your computer and use it in GitHub Desktop.
Go done wrong
func nuke(key string, in_data map[string]interface{}) error {
var err error
_, has_key := in_data[key]
if has_key == false {
err = fmt.Errorf("map does not have the requested key")
} else {
delete(in_data, key)
err = nil
}
return err
}
// create a map that contains our conversion logic
var mappings map[string] func
map["to be nuked"] = nuke
// then iterate over parsed input
var data map[string]interface{}
for key, value := range data {
// apply the function from mapping to the key and value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment