{"%#v", S{F(7), G(8)}, "fmt_test.S{F:<v=F(7)>, G:GoString(8)}"},
// %T
+ {"%T", byte(0), "uint8"},
+ {"%T", reflect.ValueOf(nil), "reflect.Value"},
{"%T", (4 - 3i), "complex128"},
{"%T", renamedComplex128(4 - 3i), "fmt_test.renamedComplex128"},
- {"%T", intVal, "int"},
- {"%6T", &intVal, " *int"},
+ {"%T", intVar, "int"},
+ {"%6T", &intVar, " *int"},
{"%10T", nil, " <nil>"},
{"%-10T", nil, "<nil> "},
// %T (the value's type) and %p (its address) are special; we always do them first.
switch verb {
case 'T':
- p.printArg(reflect.TypeOf(arg).String(), 's', 0)
+ p.fmt.fmt_s(reflect.TypeOf(arg).String())
return
case 'p':
- p.fmtPointer(reflect.ValueOf(arg), verb)
+ p.fmtPointer(reflect.ValueOf(arg), 'p')
return
}
p.arg = nil
}
-// printValue is like printArg but starts with a reflect value, not an interface{} value.
+// printValue is similar to printArg but starts with a reflect value, not an interface{} value.
+// It does not handle 'p' and 'T' verbs because these should have been already handled by printArg.
func (p *pp) printValue(value reflect.Value, verb rune, depth int) {
if !value.IsValid() {
switch verb {
- case 'T', 'v':
+ case 'v':
p.buf.WriteString(nilAngleString)
default:
p.badVerb(verb)
return
}
- // Special processing considerations.
- // %T (the value's type) and %p (its address) are special; we always do them first.
- switch verb {
- case 'T':
- p.printArg(value.Type().String(), 's', 0)
- return
- case 'p':
- p.fmtPointer(value, verb)
- return
- }
-
// Handle values with special methods.
// Call always, even when arg == nil, because handleMethods clears p.fmt.plus for us.
p.arg = nil // Make sure it's cleared, for safety.