MCPcopy Create free account
hub / github.com/google/go-cloud / IsEmptyValue

Function IsEmptyValue

docstore/driver/codec.go:745–761  ·  view source on GitHub ↗

IsEmptyValue returns whether or not v is a zero value of its type. Copied from encoding/json, go 1.12.

(v reflect.Value)

Source from the content-addressed store, hash-verified

743// IsEmptyValue returns whether or not v is a zero value of its type.
744// Copied from encoding/json, go 1.12.
745func IsEmptyValue(v reflect.Value) bool {
746 switch k := v.Kind(); k {
747 case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
748 return v.Len() == 0
749 case reflect.Bool:
750 return !v.Bool()
751 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
752 return v.Int() == 0
753 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
754 return v.Uint() == 0
755 case reflect.Float32, reflect.Float64:
756 return v.Float() == 0
757 case reflect.Interface, reflect.Pointer:
758 return v.IsNil()
759 }
760 return false
761}
762
763// Options for struct tags.
764type tagOptions struct {

Callers 7

toDriverActionMethod · 0.92
KeyMethod · 0.92
KeyMethod · 0.92
KeyMethod · 0.92
KeyMethod · 0.92
KeyMethod · 0.92
encodeStructWithFieldsFunction · 0.85

Calls 1

LenMethod · 0.45

Tested by 1

KeyMethod · 0.74