From 8b1a515cb9e8a8a43e41a3accc0000402d3b5b7e 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, 11 Oct 2023 15:05:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=9A=84=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- any.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/any.go b/any.go index c7a2597..46aa230 100644 --- a/any.go +++ b/any.go @@ -15,9 +15,11 @@ import "reflect" // // Date : 18:19 2023/6/1 func AnyDataType(data interface{}) *AnyType { - return &AnyType{ + at := &AnyType{ data: data, } + at.Type() + return at } // AnyType ... @@ -26,7 +28,8 @@ func AnyDataType(data interface{}) *AnyType { // // Date : 18:19 2023/6/1 type AnyType struct { - data interface{} + data interface{} + dataType string } // IsNil 是否为 nil @@ -44,6 +47,10 @@ func (at *AnyType) IsNil() bool { // // Date : 18:22 2023/6/1 func (at *AnyType) Type() string { + if len(at.dataType) > 0 { + // 已经处理过的,无需在处理 + return at.dataType + } if at.IsNil() { return DataTypeNil } @@ -70,5 +77,6 @@ func (at *AnyType) Type() string { // // Date : 18:32 2023/6/1 func (at *AnyType) ToString() string { + return "" }