From ba1e5f096f02c6004dba59c4b3e12e39cf6ec82c Mon Sep 17 00:00:00 2001 From: Stanly Date: Sun, 8 Dec 2024 23:57:13 +0800 Subject: [PATCH] Fix value type --- types/data.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/types/data.go b/types/data.go index b18195d..cca7560 100644 --- a/types/data.go +++ b/types/data.go @@ -31,11 +31,9 @@ func (data Data) GetSlice(key string) (res Slice, err error) { return nil, err } - switch value := value.(type) { + switch v := value.(type) { case []interface{}: - return value, nil - case Slice: - return value, nil + return v, nil default: return nil, ErrFormat } @@ -125,11 +123,9 @@ func (data Data) GetData(key string) (Data, error) { return nil, err } - switch value := value.(type) { + switch v := value.(type) { case map[string]interface{}: - return Data(value), nil - case Data: - return value, nil + return v, nil default: return nil, ErrFormat } @@ -149,9 +145,9 @@ func (data Data) GetDataSlice(key string) ([]Data, error) { } var list []Data - for _, v := range values { - switch v := v.(type) { - case Data: + for _, value := range values { + switch v := value.(type) { + case map[string]interface{}: list = append(list, v) default: return nil, ErrFormat