Created
May 1, 2019 16:11
-
-
Save flowchartsman/d428f9a013937997bd52f798e6a9e531 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
v, ok := inter.(MyType) | |
if !ok { | |
return errors.New ("nope") | |
} | |
// becomes | |
switch v := inter.(type) { | |
case MyType: | |
// do MyType stuff with v | |
default: | |
return errors.New("nope") | |
// or maybe more ideally | |
return fmt.Errorf("Unexpected type %T", v) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment