MCPcopy Create free account
hub / github.com/stretchr/objx / isEmpty

Function isEmpty

std_assert_test.go:197–213  ·  view source on GitHub ↗
(object interface{})

Source from the content-addressed store, hash-verified

195}
196
197func isEmpty(object interface{}) bool {
198 if object == nil {
199 return true
200 }
201 v := reflect.ValueOf(object)
202 switch v.Kind() {
203 case reflect.Array, reflect.Slice, reflect.Map, reflect.Chan, reflect.String:
204 return v.Len() == 0
205 case reflect.Ptr, reflect.Interface:
206 if v.IsNil() {
207 return true
208 }
209 return isEmpty(v.Elem().Interface())
210 }
211 // numbers and structs are never considered empty here
212 return false
213}
214
215func (a nonfatal) Len(t *testing.T, object interface{}, length int, msgAndArgs ...interface{}) bool {
216 t.Helper()

Callers 2

EmptyMethod · 0.85
EmptyMethod · 0.85

Calls 2

IsNilMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…