(slice interface{})
| 32 | } |
| 33 | |
| 34 | func IsEmpty(slice interface{}) bool { |
| 35 | if slice == nil { |
| 36 | return true |
| 37 | } |
| 38 | val := reflect.ValueOf(slice) |
| 39 | |
| 40 | // Check if the input is a pointer |
| 41 | if val.Kind() == reflect.Ptr { |
| 42 | // Dereference the pointer |
| 43 | val = val.Elem() |
| 44 | } |
| 45 | |
| 46 | // Check if the dereferenced value is nil |
| 47 | if !val.IsValid() { |
| 48 | return true |
| 49 | } |
| 50 | |
| 51 | kind := val.Kind() |
| 52 | |
| 53 | if kind == reflect.Slice || kind == reflect.Array || kind == reflect.Map || kind == reflect.String || |
| 54 | kind == reflect.Chan || kind == reflect.Ptr { |
| 55 | return val.Len() == 0 |
| 56 | } |
| 57 | return false |
| 58 | } |
| 59 | |
| 60 | func IsEmptyError(err errcode.Error) bool { |
| 61 | return err.Code == 0 |
no test coverage detected
searching dependent graphs…