From fc547a05b120b672b8f5ee23a95bebb56ebff98d 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 12:08:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96String=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- string.go | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) diff --git a/string.go b/string.go index 62f8d92..b3cb3dc 100644 --- a/string.go +++ b/string.go @@ -33,6 +33,25 @@ func (str String) ToFloat32() Float32Result { return res } +// ToFloat32Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:58 2023/5/16 +func (str String) ToFloat32Ptr() Float32PtrResult { + res := str.ToFloat32() + if nil != res.Err { + return Float32PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Float32PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToFloat64 ... // // Author : go_developer@163.com<白茶清欢> @@ -46,6 +65,25 @@ func (str String) ToFloat64() Float64Result { return res } +// ToFloat64Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:59 2023/5/16 +func (str String) ToFloat64Ptr() Float64PtrResult { + res := str.ToFloat64() + if nil != res.Err { + return Float64PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Float64PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToDouble 转double // // Author : go_developer@163.com<白茶清欢> @@ -55,6 +93,15 @@ func (str String) ToDouble() Float64Result { return str.ToFloat64() } +// ToDoublePtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:59 2023/5/16 +func (str String) ToDoublePtr() Float64PtrResult { + return str.ToFloat64Ptr() +} + // ToNumber 转数字, 使用最高精度的float64 // // Author : go_developer@163.com<白茶清欢> @@ -64,6 +111,15 @@ func (str String) ToNumber() Float64Result { return str.ToFloat64() } +// ToNumberPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:00 2023/5/16 +func (str String) ToNumberPtr() Float64PtrResult { + return str.ToFloat64Ptr() +} + // ToInt8 ... // // Author : go_developer@163.com<白茶清欢> @@ -77,6 +133,25 @@ func (str String) ToInt8() Int8Result { return res } +// ToInt8Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:01 2023/5/16 +func (str String) ToInt8Ptr() Int8PtrResult { + res := str.ToInt8() + if nil != res.Err { + return Int8PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Int8PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToInt16 ... // // Author : go_developer@163.com<白茶清欢> @@ -90,6 +165,25 @@ func (str String) ToInt16() Int16Result { return res } +// ToInt16Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:02 2023/5/16 +func (str String) ToInt16Ptr() Int16PtrResult { + res := str.ToInt16() + if nil != res.Err { + return Int16PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Int16PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToInt32 ... // // Author : go_developer@163.com<白茶清欢> @@ -103,6 +197,25 @@ func (str String) ToInt32() Int32Result { return res } +// ToInt32Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:03 2023/5/16 +func (str String) ToInt32Ptr() Int32PtrResult { + res := str.ToInt32() + if nil != res.Err { + return Int32PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Int32PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToInt64 ... // // Author : go_developer@163.com<白茶清欢> @@ -116,6 +229,25 @@ func (str String) ToInt64() Int64Result { return res } +// ToInt64Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:03 2023/5/16 +func (str String) ToInt64Ptr() Int64PtrResult { + res := str.ToInt64() + if nil != res.Err { + return Int64PtrResult{ + Value: nil, + Err: res.Err, + } + } + return Int64PtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToInt ... // // Author : go_developer@163.com<白茶清欢> @@ -129,6 +261,25 @@ func (str String) ToInt() IntResult { return res } +// ToIntPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:04 2023/5/16 +func (str String) ToIntPtr() IntPtrResult { + res := str.ToInt() + if nil != res.Err { + return IntPtrResult{ + Value: nil, + Err: res.Err, + } + } + return IntPtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToUint8 ... // // Author : go_developer@163.com<白茶清欢> @@ -142,6 +293,25 @@ func (str String) ToUint8() Uint8Result { return res } +// ToUint8Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:05 2023/5/16 +func (str String) ToUint8Ptr() Uint8PtrResult { + res := str.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<白茶清欢> @@ -155,6 +325,25 @@ func (str String) ToUint16() Uint16Result { return res } +// ToUint16Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:05 2023/5/16 +func (str String) ToUint16Ptr() Uint16PtrResult { + res := str.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<白茶清欢> @@ -168,6 +357,25 @@ func (str String) ToUint32() Uint32Result { return res } +// ToUint32Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:05 2023/5/16 +func (str String) ToUint32Ptr() Uint32PtrResult { + res := str.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<白茶清欢> @@ -181,6 +389,25 @@ func (str String) ToUint64() Uint64Result { return res } +// ToUint64Ptr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:06 2023/5/16 +func (str String) ToUint64Ptr() Uint64PtrResult { + res := str.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<白茶清欢> @@ -194,6 +421,25 @@ func (str String) ToUint() UintResult { return res } +// ToUintPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:06 2023/5/16 +func (str String) ToUintPtr() UintPtrResult { + res := str.ToUint() + if nil != res.Err { + return UintPtrResult{ + Value: nil, + Err: res.Err, + } + } + return UintPtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToBool ... // // Author : go_developer@163.com<白茶清欢> @@ -207,6 +453,25 @@ func (str String) ToBool() BoolResult { return res } +// ToBoolPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 12:07 2023/5/16 +func (str String) ToBoolPtr() BoolPtrResult { + res := str.ToBool() + if nil != res.Err { + return BoolPtrResult{ + Value: nil, + Err: res.Err, + } + } + return BoolPtrResult{ + Value: &res.Value, + Err: nil, + } +} + // ToObject ... // // Author : go_developer@163.com<白茶清欢>