From 77fc8f88d1abdf7ff336af564855f2764cdc3288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E9=94=9F?= Date: Fri, 10 Nov 2023 00:48:12 +0800 Subject: [PATCH] ignore empty slice Signed-off-by: kom0055 --- core/utils.go | 3 +++ test/{elegant_test.go => shuttle_test.go} | 0 2 files changed, 3 insertions(+) rename test/{elegant_test.go => shuttle_test.go} (100%) diff --git a/core/utils.go b/core/utils.go index 39a419d..d6edbd1 100644 --- a/core/utils.go +++ b/core/utils.go @@ -183,6 +183,9 @@ func shuttleUnmarshal(out any, unmarshal func(any, reflect.Type, reflect.Type) e outVal.Field(i).Set(inValIdxi) continue } + if inValIdxi.Len() == 0 { + continue + } newSliceVal := reflect.MakeSlice(outValTypeIdxi, inValIdxi.Len(), inValIdxi.Len()) for i, n := 0, inValIdxi.Len(); i < n; i++ { diff --git a/test/elegant_test.go b/test/shuttle_test.go similarity index 100% rename from test/elegant_test.go rename to test/shuttle_test.go