From 1fe7b17eb172357cc960ae791b638ed47ac0d74d Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Fri, 18 Aug 2023 21:36:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dfloat32=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=97=B6=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nreflect/convert.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nreflect/convert.go b/nreflect/convert.go index 8683052..a5e4514 100644 --- a/nreflect/convert.go +++ b/nreflect/convert.go @@ -209,7 +209,9 @@ func ValToString(rv reflect.Value, defaultAsErr bool) (str string, err error) { str = strconv.FormatBool(rv.Bool()) case reflect.String: str = rv.String() - case reflect.Float32, reflect.Float64: + case reflect.Float32: + str = strconv.FormatFloat(rv.Float(), 'f', -1, 32) + case reflect.Float64: str = strconv.FormatFloat(rv.Float(), 'f', -1, 64) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: str = strconv.FormatInt(rv.Int(), 10)