Created
November 25, 2014 18:06
-
-
Save giulioungaretti/3a741aafdf710e54f266 to your computer and use it in GitHub Desktop.
Go done wrong
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
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