Commit f73f9ad4 authored by Rob Pike's avatar Rob Pike

fmt: allow %d on []byte

Fixes #1159.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/2305043
parent 17fe2479
......@@ -317,6 +317,8 @@ var fmttests = []fmtTest{
// slices with other formats
fmtTest{"%#x", []int{1, 2, 15}, `[0x1 0x2 0xf]`},
fmtTest{"%x", []int{1, 2, 15}, `[1 2 f]`},
fmtTest{"%d", []int{1, 2, 15}, `[1 2 15]`},
fmtTest{"%d", []byte{1, 2, 15}, `[1 2 15]`},
fmtTest{"%q", []string{"a", "b"}, `["a" "b"]`},
// renamings
......@@ -334,6 +336,7 @@ var fmttests = []fmtTest{
fmtTest{"%X", renamedUint64(17), "11"},
fmtTest{"%o", renamedUintptr(18), "22"},
fmtTest{"%x", renamedString("thing"), "7468696e67"},
fmtTest{"%d", renamedBytes([]byte{1, 2, 15}), `[1 2 15]`},
fmtTest{"%q", renamedBytes([]byte("hello")), `"hello"`},
fmtTest{"%v", renamedFloat(11), "11"},
fmtTest{"%v", renamedFloat32(22), "22"},
......
......@@ -439,7 +439,7 @@ func (p *pp) fmtString(v string, verb int, goSyntax bool, value interface{}) {
}
func (p *pp) fmtBytes(v []byte, verb int, goSyntax bool, depth int, value interface{}) {
if verb == 'v' {
if verb == 'v' || verb == 'd' {
if goSyntax {
p.buf.Write(bytesBytes)
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment