Last active
August 29, 2015 14:10
-
-
Save giulioungaretti/9b56b325a160b95d3c6b to your computer and use it in GitHub Desktop.
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 maybe_string_to_int(in_value interface{}) (int, bool) { | |
switch t := in_value.(type) { | |
case string: | |
out_value, err := in_value.(int) | |
return out_value, err | |
case int, int32, int64: | |
out_value, err := in_value.(int) | |
return out_value, err | |
default: | |
// failure | |
var ouch bool | |
return 1, ouch | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment