Skip to content

Commit 59f7cb5

Browse files
committedMay 11, 2021
fix byte array display in InfoS and ErrorS
1 parent 0cc9b83 commit 59f7cb5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎klog.go

+2
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@ func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) {
825825
switch v.(type) {
826826
case string, error:
827827
b.WriteString(fmt.Sprintf("%s=%q", k, v))
828+
case []byte:
829+
b.WriteString(fmt.Sprintf("%s=%+q", k, v))
828830
default:
829831
if _, ok := v.(fmt.Stringer); ok {
830832
b.WriteString(fmt.Sprintf("%s=%q", k, v))

‎klog_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,14 @@ func TestKvListFormat(t *testing.T) {
10671067
keysValues: []interface{}{"pod", "kubedns", "values", []string{"deployment", "svc", "configmap"}},
10681068
want: " pod=\"kubedns\" values=[deployment svc configmap]",
10691069
},
1070+
{
1071+
keysValues: []interface{}{"pod", "kubedns", "bytes", []byte("test case for byte array")},
1072+
want: " pod=\"kubedns\" bytes=\"test case for byte array\"",
1073+
},
1074+
{
1075+
keysValues: []interface{}{"pod", "kubedns", "bytes", []byte("��=� ⌘")},
1076+
want: " pod=\"kubedns\" bytes=\"\\ufffd\\ufffd=\\ufffd \\u2318\"",
1077+
},
10701078
{
10711079
keysValues: []interface{}{"pod", "kubedns", "maps", map[string]int{"three": 4}},
10721080
want: " pod=\"kubedns\" maps=map[three:4]",

0 commit comments

Comments
 (0)
Please sign in to comment.