From a7bceb192c611c42ddaa1581671fde94815d7bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 1 Jun 2023 18:52:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E5=A2=9E=E5=8A=A0=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E6=95=88=E3=80=81=E6=98=AF=E5=90=A6=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E3=80=81=E8=BD=AC=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- object.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/object.go b/object.go index eafaf3c..a85b67e 100644 --- a/object.go +++ b/object.go @@ -51,3 +51,37 @@ type ObjectType struct { byteData []byte isValid bool } + +// IsValid 是否有效对象数据 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:49 2023/6/1 +func (ot *ObjectType) IsValid() bool { + return ot.isValid +} + +// IsNil 是否为nil +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:50 2023/6/1 +func (ot *ObjectType) IsNil() bool { + return ot.source == nil +} + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:51 2023/6/1 +func (ot *ObjectType) ToString() string { + if ot.IsNil() { + return "nil" + } + if !ot.IsValid() { + // 非法对象数据 + return "" + } + return string(ot.byteData) +}