github.com/searKing/golang/go@v1.2.74/util/object/zero_go1.13.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build go1.13 6 7 package object 8 9 import "reflect" 10 11 // IsZero reports whether a value is a zero value of its kind. 12 // If value.Kind() is Struct, it traverses each field of the struct 13 // recursively calling IsZero, returning true only if each field's IsZero 14 // result is also true. 15 func IsZero(obj interface{}) bool { 16 var v reflect.Value 17 if vv, ok := obj.(reflect.Value); ok { 18 v = vv 19 } else { 20 v = reflect.ValueOf(obj) 21 } 22 return v.IsZero() 23 }