Skip to content

Instantly share code, notes, and snippets.

@hajimehoshi
Created June 30, 2018 09:15
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 hajimehoshi/cf247e11f2b668a11bbd1357663c3435 to your computer and use it in GitHub Desktop.
Save hajimehoshi/cf247e11f2b668a11bbd1357663c3435 to your computer and use it in GitHub Desktop.
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