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<白茶清欢>