From 1496ea281e315963399e9da4955d383f94a353af Mon Sep 17 00:00:00 2001 From: lxzan Date: Fri, 23 Feb 2024 14:29:16 +0800 Subject: [PATCH] fix --- algo/algorithm.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/algo/algorithm.go b/algo/algorithm.go index ecafee9..3d3ad1b 100644 --- a/algo/algorithm.go +++ b/algo/algorithm.go @@ -155,7 +155,14 @@ func IsNil(v any) bool { if v == nil { return true } - return reflect.ValueOf(v).IsNil() + + var value = reflect.ValueOf(v) + switch value.Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer, reflect.Slice, reflect.Interface: + return value.IsNil() + default: + return v == nil + } } // NotNil 判断不为空