获取int类型指针

This commit is contained in:
白茶清欢 2023-05-15 17:53:24 +08:00
parent 763009ad36
commit 88833ed039
2 changed files with 29 additions and 0 deletions

View File

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

19
int.go
View File

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