From abbfdf57754e999e48c222db1db9c909a06117b0 Mon Sep 17 00:00:00 2001 From: illia-li Date: Tue, 8 Oct 2024 22:11:28 -0400 Subject: [PATCH] fix errors `tinyint` --- marshal/tinyint/marshal_utils.go | 10 +++++----- marshal/tinyint/unmarshal.go | 2 +- marshal/tinyint/unmarshal_utils.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/marshal/tinyint/marshal_utils.go b/marshal/tinyint/marshal_utils.go index 0ac508a24..5bf9b477c 100644 --- a/marshal/tinyint/marshal_utils.go +++ b/marshal/tinyint/marshal_utils.go @@ -168,7 +168,7 @@ func EncString(v string) ([]byte, error) { n, err := strconv.ParseInt(v, 10, 8) if err != nil { - return nil, fmt.Errorf("failed to marshal tinyint: can not marshal %#v %s", v, err) + return nil, fmt.Errorf("failed to marshal tinyint: can not marshal (%T)(%[1]v) %s", v, err) } return []byte{byte(n)}, nil } @@ -187,7 +187,7 @@ func EncReflect(v reflect.Value) ([]byte, error) { case reflect.Int, reflect.Int64, reflect.Int32, reflect.Int16: val := v.Int() if val > math.MaxInt8 || val < math.MinInt8 { - return nil, fmt.Errorf("failed to marshal tinyint: value %#v out of range", v.Interface()) + return nil, fmt.Errorf("failed to marshal tinyint: value (%T)(%[1]v) out of range", v.Interface()) } return []byte{byte(val)}, nil case reflect.Uint8: @@ -195,7 +195,7 @@ func EncReflect(v reflect.Value) ([]byte, error) { case reflect.Uint, reflect.Uint64, reflect.Uint32, reflect.Uint16: val := v.Uint() if val > math.MaxUint8 { - return nil, fmt.Errorf("failed to marshal tinyint: value %#v out of range", v.Interface()) + return nil, fmt.Errorf("failed to marshal tinyint: value (%T)(%[1]v) out of range", v.Interface()) } return []byte{byte(val)}, nil case reflect.String: @@ -206,11 +206,11 @@ func EncReflect(v reflect.Value) ([]byte, error) { n, err := strconv.ParseInt(val, 10, 8) if err != nil { - return nil, fmt.Errorf("failed to marshal tinyint: can not marshal %#v %s", v.Interface(), err) + return nil, fmt.Errorf("failed to marshal tinyint: can not marshal (%T)(%[1]v) %s", v.Interface(), err) } return []byte{byte(n)}, nil default: - return nil, fmt.Errorf("failed to marshal tinyint: unsupported value type (%T)(%#[1]v)", v.Interface()) + return nil, fmt.Errorf("failed to marshal tinyint: unsupported value type (%T)(%[1]v)", v.Interface()) } } diff --git a/marshal/tinyint/unmarshal.go b/marshal/tinyint/unmarshal.go index 7f3944498..3e1f71908 100644 --- a/marshal/tinyint/unmarshal.go +++ b/marshal/tinyint/unmarshal.go @@ -71,7 +71,7 @@ func Unmarshal(data []byte, value interface{}) error { rv := reflect.ValueOf(value) rt := rv.Type() if rt.Kind() != reflect.Ptr { - return fmt.Errorf("failed to unmarshal tinyint: unsupported value type %#v", value) + return fmt.Errorf("failed to unmarshal tinyint: unsupported value type (%T)(%[1]v)", v) } if rt.Elem().Kind() != reflect.Ptr { return DecReflect(data, rv) diff --git a/marshal/tinyint/unmarshal_utils.go b/marshal/tinyint/unmarshal_utils.go index c129069f7..d2762b3ec 100644 --- a/marshal/tinyint/unmarshal_utils.go +++ b/marshal/tinyint/unmarshal_utils.go @@ -11,7 +11,7 @@ import ( var errWrongDataLen = fmt.Errorf("failed to unmarshal tinyint: the length of the data should less or equal then 1") func errNilReference(v interface{}) error { - return fmt.Errorf("failed to unmarshal tinyint: can not unmarshal into nil reference %#v)", v) + return fmt.Errorf("failed to unmarshal tinyint: can not unmarshal into nil reference(%T)(%[1]v)", v) } func DecInt8(p []byte, v *int8) error { @@ -451,7 +451,7 @@ func DecReflect(p []byte, v reflect.Value) error { case reflect.String: return decReflectString(p, v) default: - return fmt.Errorf("failed to unmarshal tinyint: unsupported value type %#v)", v.Interface()) + return fmt.Errorf("failed to unmarshal tinyint: unsupported value type (%T)(%[1]v)", v.Interface()) } } @@ -468,7 +468,7 @@ func DecReflectR(p []byte, v reflect.Value) error { case reflect.String: return decReflectStringR(p, v) default: - return fmt.Errorf("failed to unmarshal tinyint: unsupported value type (%T)(%#[1]v)", v.Interface()) + return fmt.Errorf("failed to unmarshal tinyint: unsupported value type (%T)(%[1]v)", v.Interface()) } }