From 6741dcf03374eb585e38f1e48d0e13ebda070139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 5 May 2023 10:48:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- string_convert.go | 96 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/string_convert.go b/string_convert.go index b270bc9..767b26e 100644 --- a/string_convert.go +++ b/string_convert.go @@ -22,7 +22,12 @@ type stringConvert struct { // // Date : 18:26 2023/5/4 func (sc *stringConvert) ToFloat32(str string) (float32, error) { - return 0, nil + var ( + err error + res float32 + ) + err = ConvertAssign(&res, str) + return res, err } // ToFloat64 ... @@ -31,7 +36,12 @@ func (sc *stringConvert) ToFloat32(str string) (float32, error) { // // Date : 18:26 2023/5/4 func (sc *stringConvert) ToFloat64(str string) (float64, error) { - return 0, nil + var ( + err error + res float64 + ) + err = ConvertAssign(&res, str) + return res, err } // ToDouble 转double @@ -58,7 +68,12 @@ func (sc *stringConvert) ToNumber(str string) (float64, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToInt8(str string) (int8, error) { - return 0, nil + var ( + err error + res int8 + ) + err = ConvertAssign(&res, str) + return res, err } // ToInt16 ... @@ -67,7 +82,12 @@ func (sc *stringConvert) ToInt8(str string) (int8, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToInt16(str string) (int16, error) { - return 0, nil + var ( + err error + res int16 + ) + err = ConvertAssign(&res, str) + return res, err } // ToInt32 ... @@ -76,7 +96,12 @@ func (sc *stringConvert) ToInt16(str string) (int16, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToInt32(str string) (int32, error) { - return 0, nil + var ( + err error + res int32 + ) + err = ConvertAssign(&res, str) + return res, err } // ToInt64 ... @@ -85,11 +110,26 @@ func (sc *stringConvert) ToInt32(str string) (int32, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToInt64(str string) (int64, error) { - return 0, nil + var ( + err error + res int64 + ) + err = ConvertAssign(&res, str) + return res, err } +// ToInt ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:47 2023/5/5 func (sc *stringConvert) ToInt(str string) (int, error) { - return 0, nil + var ( + err error + res int + ) + err = ConvertAssign(&res, str) + return res, err } // ToUint8 ... @@ -98,7 +138,12 @@ func (sc *stringConvert) ToInt(str string) (int, error) { // // Date : 18:30 2023/5/4 func (sc *stringConvert) ToUint8(str string) (uint8, error) { - return 0, nil + var ( + err error + res uint8 + ) + err = ConvertAssign(&res, str) + return res, err } // ToUint16 ... @@ -107,7 +152,12 @@ func (sc *stringConvert) ToUint8(str string) (uint8, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToUint16(str string) (uint16, error) { - return 0, nil + var ( + err error + res uint16 + ) + err = ConvertAssign(&res, str) + return res, err } // ToUint32 ... @@ -116,7 +166,12 @@ func (sc *stringConvert) ToUint16(str string) (uint16, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToUint32(str string) (uint32, error) { - return 0, nil + var ( + err error + res uint32 + ) + err = ConvertAssign(&res, str) + return res, err } // ToUint64 ... @@ -125,7 +180,12 @@ func (sc *stringConvert) ToUint32(str string) (uint32, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToUint64(str string) (uint64, error) { - return 0, nil + var ( + err error + res uint64 + ) + err = ConvertAssign(&res, str) + return res, err } // ToUint ... @@ -134,7 +194,12 @@ func (sc *stringConvert) ToUint64(str string) (uint64, error) { // // Date : 18:29 2023/5/4 func (sc *stringConvert) ToUint(str string) (uint, error) { - return 0, nil + var ( + err error + res uint + ) + err = ConvertAssign(&res, str) + return res, err } // ToBool ... @@ -143,7 +208,12 @@ func (sc *stringConvert) ToUint(str string) (uint, error) { // // Date : 18:34 2023/5/4 func (sc *stringConvert) ToBool(str string) (bool, error) { - return false, nil + var ( + err error + res bool + ) + err = ConvertAssign(&res, str) + return res, err } // ToObject ...