Merge 6d6046a9de
into 3e74359719
This commit is contained in:
commit
31a876680a
|
@ -150,11 +150,26 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
|
||||||
switch iface := viface.(type) {
|
switch iface := viface.(type) {
|
||||||
case error:
|
case error:
|
||||||
defer catchPanic(w, v)
|
defer catchPanic(w, v)
|
||||||
|
if cs.ContinueOnMethod {
|
||||||
|
w.Write(append(openParenBytes, []byte(iface.Error())...))
|
||||||
|
w.Write(closeParenBytes)
|
||||||
|
w.Write(spaceBytes)
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
w.Write([]byte(iface.Error()))
|
w.Write([]byte(iface.Error()))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
defer catchPanic(w, v)
|
defer catchPanic(w, v)
|
||||||
|
if cs.ContinueOnMethod {
|
||||||
|
w.Write(append(openParenBytes, []byte(iface.String())...))
|
||||||
|
w.Write(closeParenBytes)
|
||||||
|
w.Write(spaceBytes)
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
w.Write([]byte(iface.String()))
|
w.Write([]byte(iface.String()))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,13 @@ type ConfigState struct {
|
||||||
// interface with a pointer receiver should not be mutating their state
|
// interface with a pointer receiver should not be mutating their state
|
||||||
// inside these interface methods.
|
// inside these interface methods.
|
||||||
DisablePointerMethods bool
|
DisablePointerMethods bool
|
||||||
|
|
||||||
|
//ContinueOnMethod specifies whether recursion should stop once
|
||||||
|
//a Stringer or an error interface is encountered.
|
||||||
|
//
|
||||||
|
//It defaults to false, meaning that it does not pretty-print
|
||||||
|
//the internals of Stringers or errors.
|
||||||
|
ContinueOnMethod bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is the active configuration of the top-level functions.
|
// Config is the active configuration of the top-level functions.
|
||||||
|
|
Loading…
Reference in New Issue