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) +}