优化Uint类型

This commit is contained in:
白茶清欢 2023-05-16 11:00:23 +08:00
parent 58073c7f5b
commit 1b9800a6ee
2 changed files with 184 additions and 0 deletions

View File

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

114
uint.go
View File

@ -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,
}
}