MCPcopy
hub / github.com/harness/harness / IsEmpty

Function IsEmpty

registry/app/pkg/commons/request.go:34–58  ·  view source on GitHub ↗
(slice interface{})

Source from the content-addressed store, hash-verified

32}
33
34func 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
60func IsEmptyError(err errcode.Error) bool {
61 return err.Code == 0

Callers 15

ProxyManifestMethod · 0.92
CreateOrUpdateMethod · 0.92
ModifyCleanupPoliciesMethod · 0.92
CreateOrUpdateMethod · 0.92
CountAllByRegistryMethod · 0.92
CountAllMethod · 0.92
GetPackageMetadataMethod · 0.92
PatchBlobUploadMethod · 0.92

Calls 2

IsValidMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…