From 122001ce32fe30ecea6d7a703360b9b8d4eddcb2 Mon Sep 17 00:00:00 2001 From: fgy Date: Fri, 27 Sep 2024 16:28:41 +0800 Subject: [PATCH] feat: avoid typed nil --- cmd/hz/generator/package_tpl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/hz/generator/package_tpl.go b/cmd/hz/generator/package_tpl.go index 2ef717429..7b8e2f46d 100644 --- a/cmd/hz/generator/package_tpl.go +++ b/cmd/hz/generator/package_tpl.go @@ -593,6 +593,9 @@ func (r *request) setQueryParam(param string, value interface{}) *request { return r } v := reflect.ValueOf(value) + if v.Kind() == reflect.Pointer && v.IsNil() { + return r + } switch v.Kind() { case reflect.Slice, reflect.Array: for index := 0; index < v.Len(); index++ {