Created
June 30, 2018 09:15
-
-
Save hajimehoshi/cf247e11f2b668a11bbd1357663c3435 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 isNil(v interface{}) bool { | |
if v == nil { | |
return true | |
} | |
switch rv := reflect.ValueOf(v); rv.Kind() { | |
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Slice: | |
return rv.IsNil() | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment