mirror of
https://github.com/golang/go
synced 2024-11-22 00:44:39 -07:00
fmt: %T print <nil> for nil
R=r CC=golang-dev, rsc https://golang.org/cl/1014043
This commit is contained in:
parent
96179629ef
commit
1331f8b3cb
@ -264,6 +264,7 @@ var fmttests = []fmtTest{
|
|||||||
fmtTest{"%d", "hello", "%d(string=hello)"},
|
fmtTest{"%d", "hello", "%d(string=hello)"},
|
||||||
fmtTest{"no args", "hello", "no args?(extra string=hello)"},
|
fmtTest{"no args", "hello", "no args?(extra string=hello)"},
|
||||||
fmtTest{"%s", nil, "%s(<nil>)"},
|
fmtTest{"%s", nil, "%s(<nil>)"},
|
||||||
|
fmtTest{"%T", nil, "<nil>"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSprintf(t *testing.T) {
|
func TestSprintf(t *testing.T) {
|
||||||
|
@ -1030,6 +1030,10 @@ func (p *pp) doprintf(format string, a []interface{}) {
|
|||||||
|
|
||||||
// the value's type
|
// the value's type
|
||||||
case 'T':
|
case 'T':
|
||||||
|
if field == nil {
|
||||||
|
p.buf.Write(nilAngleBytes)
|
||||||
|
break
|
||||||
|
}
|
||||||
p.buf.WriteString(reflect.Typeof(field).String())
|
p.buf.WriteString(reflect.Typeof(field).String())
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user