From cff5d4361024df4bc6ef47969c22d5030b1b8f35 Mon Sep 17 00:00:00 2001 From: Kuisong Tong Date: Sun, 10 Mar 2024 20:33:21 -0700 Subject: [PATCH] reduce var (#235) --- internal/convert/converter.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/convert/converter.go b/internal/convert/converter.go index 0b0af117..b76bd0cf 100644 --- a/internal/convert/converter.go +++ b/internal/convert/converter.go @@ -415,8 +415,7 @@ func (c Converter) convertSlice(name string, fromVal, toVal reflect.Value) error return errors.Join(errs...) case fromVal.Kind() == reflect.String && toVal.Type().Elem().Kind() == reflect.Uint8: - s := fromVal.String() - toVal.SetBytes(internal.String2ByteSlice(s)) + toVal.SetBytes(internal.String2ByteSlice(fromVal.String())) case fromVal.Kind() == reflect.Map: // Empty maps turn into empty arrays if fromVal.Len() == 0 { @@ -459,8 +458,7 @@ func (c Converter) convertString(name string, fromVal, toVal reflect.Value) erro reflect.Copy(reflect.ValueOf(bytes), fromVal) toVal.SetString(internal.ByteSlice2String(bytes)) case fromVal.Kind() == reflect.Slice && fromVal.Type().Elem().Kind() == reflect.Uint8: - bytes := fromVal.Bytes() - toVal.SetString(internal.ByteSlice2String(bytes)) + toVal.SetString(internal.ByteSlice2String(fromVal.Bytes())) default: return fmt.Errorf( //nolint:goerr113 "'%s' expected type '%s', got unconvertible type '%s', value: '%v'",