From dac3a32e6f2700d74b09a0c01ff80c731ab5c442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 6 Nov 2024 18:29:18 +0800 Subject: [PATCH] easy map --- easymap.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/easymap.go b/easymap.go index 6013835..cbd2a56 100644 --- a/easymap.go +++ b/easymap.go @@ -21,7 +21,7 @@ import ( // Author : go_developer@163.com<白茶清欢> // // Date : 15:02 2023/8/10 -func EasyMap(mapData any) Map { +func EasyMap(mapData any) easymap.EasyMap { m, _ := EasyMapWithError(mapData) return m } @@ -31,7 +31,7 @@ func EasyMap(mapData any) Map { // Author : go_developer@163.com<白茶清欢> // // Date : 15:06 2023/8/10 -func EasyMapWithError(mapData any) (Map, error) { +func EasyMapWithError(mapData any) (easymap.EasyMap, error) { if nil == mapData { return easymap.NewNormal(), nil } @@ -58,7 +58,7 @@ func EasyMapWithError(mapData any) (Map, error) { // Author : go_developer@163.com<白茶清欢> // // Date : 16:11 2023/8/10 -func EasyMapFromStruct(data any) Map { +func EasyMapFromStruct(data any) easymap.EasyMap { byteData, _ := json.Marshal(data) return EasyMapFromByte(byteData) } @@ -68,7 +68,7 @@ func EasyMapFromStruct(data any) Map { // Author : go_developer@163.com<白茶清欢> // // Date : 16:12 2023/8/10 -func EasyMapFromString(data string) Map { +func EasyMapFromString(data string) easymap.EasyMap { return EasyMapFromByte([]byte(data)) } @@ -77,7 +77,7 @@ func EasyMapFromString(data string) Map { // Author : go_developer@163.com<白茶清欢> // // Date : 16:12 2023/8/10 -func EasyMapFromByte(data []byte) Map { +func EasyMapFromByte(data []byte) easymap.EasyMap { res := easymap.NewNormal() jsonRes := gjson.Parse(string(data)) jsonRes.ForEach(func(key, value gjson.Result) bool { @@ -86,10 +86,3 @@ func EasyMapFromByte(data []byte) Map { }) return res } - -// Map ... -// -// Author : go_developer@163.com<白茶清欢> -// -// Date : 15:14 2023/8/10 -type Map easymap.EasyMap