MCPcopy
hub / github.com/redis/go-redis / isEmptyValue

Function isEmptyValue

commands.go:149–171  ·  view source on GitHub ↗
(v reflect.Value)

Source from the content-addressed store, hash-verified

147}
148
149func isEmptyValue(v reflect.Value) bool {
150 switch v.Kind() {
151 case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
152 return v.Len() == 0
153 case reflect.Bool:
154 return !v.Bool()
155 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
156 return v.Int() == 0
157 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
158 return v.Uint() == 0
159 case reflect.Float32, reflect.Float64:
160 return v.Float() == 0
161 case reflect.Interface, reflect.Pointer:
162 return v.IsNil()
163 case reflect.Struct:
164 if v.Type() == reflect.TypeOf(time.Time{}) {
165 return v.IsZero()
166 }
167 // Only supports the struct time.Time,
168 // subsequent iterations will follow the func Scan support decoder.
169 }
170 return false
171}
172
173type Cmdable interface {
174 Pipeline() Pipeliner

Callers 1

appendStructFieldFunction · 0.85

Calls 4

LenMethod · 0.65
TypeMethod · 0.65
BoolMethod · 0.45
IntMethod · 0.45

Tested by

no test coverage detected