From 1b9800a6eed1b8913dd76dd03b15fdcd1e8459f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 16 May 2023 11:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Uint=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define.go | 70 +++++++++++++++++++++++++++++++++ uint.go | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/define.go b/define.go index c8f8650..7be8ea1 100644 --- a/define.go +++ b/define.go @@ -154,6 +154,16 @@ type Uint8Result struct { Err error } +// Uint8PtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:49 2023/5/16 +type Uint8PtrResult struct { + Value *uint8 + Err error +} + // Uint16Result ... // // Author : go_developer@163.com<白茶清欢> @@ -164,6 +174,16 @@ type Uint16Result struct { Err error } +// Uint16PtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:49 2023/5/16 +type Uint16PtrResult struct { + Value *uint16 + Err error +} + // Uint32Result ... // // Author : go_developer@163.com<白茶清欢> @@ -174,6 +194,16 @@ type Uint32Result struct { Err error } +// Uint32PtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:49 2023/5/16 +type Uint32PtrResult struct { + Value *uint32 + Err error +} + // Uint64Result ... // // Author : go_developer@163.com<白茶清欢> @@ -184,6 +214,16 @@ type Uint64Result struct { Err error } +// Uint64PtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:50 2023/5/16 +type Uint64PtrResult struct { + Value *uint64 + Err error +} + // UintResult ... // // Author : go_developer@163.com<白茶清欢> @@ -194,6 +234,16 @@ type UintResult struct { Err error } +// UintPtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:51 2023/5/16 +type UintPtrResult struct { + Value *uint + Err error +} + // Float32Result ... // // Author : go_developer@163.com<白茶清欢> @@ -214,6 +264,16 @@ type Float64Result struct { Err error } +// Float64PtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:52 2023/5/16 +type Float64PtrResult struct { + Value *float64 + Err error +} + // Any ... // // Author : go_developer@163.com<白茶清欢> @@ -234,6 +294,16 @@ type BoolResult struct { Err error } +// BoolPtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:53 2023/5/16 +type BoolPtrResult struct { + Value *bool + Err error +} + // ObjectResult ... // // Author : go_developer@163.com<白茶清欢> diff --git a/uint.go b/uint.go index 69e574c..bf0dcfb 100644 --- a/uint.go +++ b/uint.go @@ -37,6 +37,25 @@ func (ui Uint) ToUint8() Uint8Result { return res } +// ToUint8Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:54 2023/5/16 +func (ui Uint) ToUint8Ptr() Uint8PtrResult { + res := ui.ToUint8() + if nil != res.Err { + return Uint8PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Uint8PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToUint16 ... // // Author : go_developer@163.com<白茶清欢> @@ -55,6 +74,25 @@ func (ui Uint) ToUint16() Uint16Result { return res } +// ToUint16Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:55 2023/5/16 +func (ui Uint) ToUint16Ptr() Uint16PtrResult { + res := ui.ToUint16() + if nil != res.Err { + return Uint16PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Uint16PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToUint32 ... // // Author : go_developer@163.com<白茶清欢> @@ -73,6 +111,25 @@ func (ui Uint) ToUint32() Uint32Result { return res } +// ToUint32Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:55 2023/5/16 +func (ui Uint) ToUint32Ptr() Uint32PtrResult { + res := ui.ToUint32() + if nil != res.Err { + return Uint32PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Uint32PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToUint64 ... // // Author : go_developer@163.com<白茶清欢> @@ -90,6 +147,25 @@ func (ui Uint) ToUint64() Uint64Result { return res } +// ToUint64Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:57 2023/5/16 +func (ui Uint) ToUint64Ptr() Uint64PtrResult { + res := ui.ToUint64() + if nil != res.Err { + return Uint64PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Uint64PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToUint ... // // Author : go_developer@163.com<白茶清欢> @@ -108,6 +184,25 @@ func (ui Uint) ToUint() UintResult { return res } +// ToUintPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:57 2023/5/16 +func (ui Uint) ToUintPtr() UintPtrResult { + res := ui.ToUint() + if nil != res.Err { + return UintPtrResult{ + Value: nil, + Err: res.Err, + } + } + return UintPtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToString ... // // Author : go_developer@163.com<白茶清欢> @@ -126,3 +221,22 @@ func (ui Uint) ToString() StringResult { Err: nil, } } + +// ToStringPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:59 2023/5/16 +func (ui Uint) ToStringPtr() StringPtrResult { + res := ui.ToString() + if nil != res.Err { + return StringPtrResult{ + Value: nil, + Err: res.Err, + } + } + return StringPtrResult{ + Value: &res.Value, + Err: nil, + } +}