Commit 1331f8b3 authored by Christopher Wedgwood's avatar Christopher Wedgwood Committed by Rob Pike

fmt: %T print <nil> for nil

R=r
CC=golang-dev, rsc
https://golang.org/cl/1014043
parent 96179629
......@@ -264,6 +264,7 @@ var fmttests = []fmtTest{
fmtTest{"%d", "hello", "%d(string=hello)"},
fmtTest{"no args", "hello", "no args?(extra string=hello)"},
fmtTest{"%s", nil, "%s(<nil>)"},
fmtTest{"%T", nil, "<nil>"},
}
func TestSprintf(t *testing.T) {
......
......@@ -1030,6 +1030,10 @@ func (p *pp) doprintf(format string, a []interface{}) {
// the value's type
case 'T':
if field == nil {
p.buf.Write(nilAngleBytes)
break
}
p.buf.WriteString(reflect.Typeof(field).String())
default:
......
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