}
var (
- osErrorType = reflect.TypeOf((*error)(nil)).Elem()
+ errorType = reflect.TypeOf((*error)(nil)).Elem()
fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
)
return
}
- if !v.Type().Implements(fmtStringerType) {
+ if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) {
if v.CanAddr() && reflect.PtrTo(v.Type()).Implements(fmtStringerType) {
v = v.Addr()
} else {
import (
"bytes"
+ "errors"
"flag"
"fmt"
"os"
NonEmptyInterface I
// Stringer.
Str fmt.Stringer
+ Err error
// Pointers
PI *int
PSI *[]int
Empty4: &U{"UinEmpty"},
NonEmptyInterface: new(T),
Str: bytes.NewBuffer([]byte("foozle")),
+ Err: errors.New("erroozle"),
PI: newInt(23),
PSI: newIntSlice(21, 22, 23),
Tmpl: Must(New("x").Parse("test template")), // "x" is the value of .X
{"bug4", "{{if .Empty0}}non-nil{{else}}nil{{end}}", "nil", tVal, true},
// Stringer.
{"bug5", "{{.Str}}", "foozle", tVal, true},
+ {"bug5a", "{{.Err}}", "erroozle", tVal, true},
// Args need to be indirected and dereferenced sometimes.
{"bug6a", "{{vfunc .V0 .V1}}", "vfunc", tVal, true},
{"bug6b", "{{vfunc .V0 .V0}}", "vfunc", tVal, true},