From 88833ed0395a5386e5d5676e70bcf1bdcaba8ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 15 May 2023 17:53:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96int=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define.go | 10 ++++++++++ int.go | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/define.go b/define.go index 387fd0a..886bcbe 100644 --- a/define.go +++ b/define.go @@ -94,6 +94,16 @@ type IntResult struct { Err error } +// IntPtrResult ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:51 2023/5/15 +type IntPtrResult struct { + Value *int + Err error +} + // Uint8Result ... // // Author : go_developer@163.com<白茶清欢> diff --git a/int.go b/int.go index 29cb8cb..f5ca495 100644 --- a/int.go +++ b/int.go @@ -108,6 +108,25 @@ func (i Int) ToInt() IntResult { return res } +// ToIntPtr ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:52 2023/5/15 +func (i Int) ToIntPtr() IntPtrResult { + intRes := i.ToInt() + if nil != intRes.Err { + return IntPtrResult{ + Value: nil, + Err: intRes.Err, + } + } + return IntPtrResult{ + Value: &intRes.Value, + Err: nil, + } +} + // ToString ... // // Author : go_developer@163.com<白茶清欢>