Back to Lo

Core Isnil

docs/data/core-isnil.md

1.53.0394 B
Original Source

Returns true if the input is nil or points to a nil value. This works with pointers, interfaces, maps, slices, channels, and functions.

go
result := lo.IsNil(nil)
// true

var ptr *int
result = lo.IsNil(ptr)
// true

result = lo.IsNil(42)
// false

result = lo.IsNil("hello")
// false

var iface interface{}
result = lo.IsNil(iface)
// true

iface = 42
result = lo.IsNil(iface)
// false