Cleanup documentation on new ContinueOnMethod code.
This commit expands on TShadwell's work attached to issue #8. It rounds out the documentation for the new option.
This commit is contained in:
parent
6d6046a9de
commit
9dfc238865
|
@ -109,6 +109,10 @@ options. See the ConfigState documentation for more details.
|
||||||
Disables invocation of error and Stringer interface methods on types
|
Disables invocation of error and Stringer interface methods on types
|
||||||
which only accept pointer receivers from non-pointer variables.
|
which only accept pointer receivers from non-pointer variables.
|
||||||
Pointer method invocation is enabled by default.
|
Pointer method invocation is enabled by default.
|
||||||
|
|
||||||
|
* ContinueOnMethod
|
||||||
|
Enables recursion into types after invoking error and Stringer interface
|
||||||
|
methods. Recursion after method invocation is disabled by default.
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
@ -151,10 +151,10 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
|
||||||
case error:
|
case error:
|
||||||
defer catchPanic(w, v)
|
defer catchPanic(w, v)
|
||||||
if cs.ContinueOnMethod {
|
if cs.ContinueOnMethod {
|
||||||
w.Write(append(openParenBytes, []byte(iface.Error())...))
|
w.Write(openParenBytes)
|
||||||
|
w.Write([]byte(iface.Error()))
|
||||||
w.Write(closeParenBytes)
|
w.Write(closeParenBytes)
|
||||||
w.Write(spaceBytes)
|
w.Write(spaceBytes)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,10 +164,10 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
defer catchPanic(w, v)
|
defer catchPanic(w, v)
|
||||||
if cs.ContinueOnMethod {
|
if cs.ContinueOnMethod {
|
||||||
w.Write(append(openParenBytes, []byte(iface.String())...))
|
w.Write(openParenBytes)
|
||||||
|
w.Write([]byte(iface.String()))
|
||||||
w.Write(closeParenBytes)
|
w.Write(closeParenBytes)
|
||||||
w.Write(spaceBytes)
|
w.Write(spaceBytes)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
w.Write([]byte(iface.String()))
|
w.Write([]byte(iface.String()))
|
||||||
|
|
|
@ -63,11 +63,14 @@ type ConfigState struct {
|
||||||
// inside these interface methods.
|
// inside these interface methods.
|
||||||
DisablePointerMethods bool
|
DisablePointerMethods bool
|
||||||
|
|
||||||
//ContinueOnMethod specifies whether recursion should stop once
|
// ContinueOnMethod specifies whether or not recursion should continue once
|
||||||
//a Stringer or an error interface is encountered.
|
// a custom error or Stringer interface is invoked. The default, false,
|
||||||
|
// means it will print the results of invoking the custom error or Stringer
|
||||||
|
// interface and return immediately instead of continuing to recurse into
|
||||||
|
// the internals of the data type.
|
||||||
//
|
//
|
||||||
//It defaults to false, meaning that it does not pretty-print
|
// NOTE: This flag does not have any effect if method invocation is disabled
|
||||||
//the internals of Stringers or errors.
|
// via the DisableMethods or DisablePointerMethods options.
|
||||||
ContinueOnMethod bool
|
ContinueOnMethod bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,10 +258,11 @@ func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{})
|
||||||
|
|
||||||
// NewDefaultConfig returns a ConfigState with the following default settings.
|
// NewDefaultConfig returns a ConfigState with the following default settings.
|
||||||
//
|
//
|
||||||
// Indent: " "
|
// Indent: " "
|
||||||
// MaxDepth: 0
|
// MaxDepth: 0
|
||||||
// DisableMethods: false
|
// DisableMethods: false
|
||||||
// DisablePointerMethods: false
|
// DisablePointerMethods: false
|
||||||
|
// ContinueOnMethod: false
|
||||||
func NewDefaultConfig() *ConfigState {
|
func NewDefaultConfig() *ConfigState {
|
||||||
return &ConfigState{Indent: " "}
|
return &ConfigState{Indent: " "}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,10 @@ The following configuration options are available:
|
||||||
which only accept pointer receivers from non-pointer variables.
|
which only accept pointer receivers from non-pointer variables.
|
||||||
Pointer method invocation is enabled by default.
|
Pointer method invocation is enabled by default.
|
||||||
|
|
||||||
|
* ContinueOnMethod
|
||||||
|
Enables recursion into types after invoking error and Stringer interface
|
||||||
|
methods. Recursion after method invocation is disabled by default.
|
||||||
|
|
||||||
Dump Usage
|
Dump Usage
|
||||||
|
|
||||||
Simply call spew.Dump with a list of variables you want to dump:
|
Simply call spew.Dump with a list of variables you want to dump:
|
||||||
|
|
Loading…
Reference in New Issue