Skip to content

Instantly share code, notes, and snippets.

@giulioungaretti
Last active August 29, 2015 14:10
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/9b56b325a160b95d3c6b to your computer and use it in GitHub Desktop.
Save giulioungaretti/9b56b325a160b95d3c6b to your computer and use it in GitHub Desktop.
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