From 24862349c6aca34308d4fe80471efa409bae1dcc Mon Sep 17 00:00:00 2001 From: Masahiro Furudate <178inaba.git@gmail.com> Date: Thu, 14 May 2020 05:10:35 +0900 Subject: [PATCH] Fix uint8 to format in decimal --- cmp/report_reflect.go | 5 ++--- cmp/report_slices.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cmp/report_reflect.go b/cmp/report_reflect.go index b10ccd8..3d59492 100644 --- a/cmp/report_reflect.go +++ b/cmp/report_reflect.go @@ -108,10 +108,9 @@ func (opts formatOptions) FormatValue(v reflect.Value, m visitedPointers) (out t return textLine(fmt.Sprint(v.Bool())) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return textLine(fmt.Sprint(v.Int())) - case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return textLine(fmt.Sprint(v.Uint())) - case reflect.Uint8, reflect.Uintptr: - // If it is uint8 which is an alias of byte, format it to hex. + case reflect.Uintptr: return textLine(formatHex(v.Uint())) case reflect.Float32, reflect.Float64: return textLine(fmt.Sprint(v.Float())) diff --git a/cmp/report_slices.go b/cmp/report_slices.go index 68e810a..b5e2894 100644 --- a/cmp/report_slices.go +++ b/cmp/report_slices.go @@ -172,10 +172,9 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode { switch t.Elem().Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ss = append(ss, fmt.Sprint(v.Index(i).Int())) - case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: ss = append(ss, fmt.Sprint(v.Index(i).Uint())) - case reflect.Uint8, reflect.Uintptr: - // If it is uint8 which is an alias of byte, format it to hex. + case reflect.Uintptr: ss = append(ss, formatHex(v.Index(i).Uint())) case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128: ss = append(ss, fmt.Sprint(v.Index(i).Interface()))