diff --git a/README.md b/README.md index 71dd308..9095c64 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,16 @@ if result != nil { } ``` +or + +```go +func init() { + multierror.ListFormatFunc = func([]error) string { + return "errors!" + } +} +``` + **Accessing the list of errors** `multierror.Error` implements `error` so if the caller doesn't know about diff --git a/format.go b/format.go index 47f13c4..7b2b699 100644 --- a/format.go +++ b/format.go @@ -11,7 +11,7 @@ type ErrorFormatFunc func([]error) string // ListFormatFunc is a basic formatter that outputs the number of errors // that occurred along with a bullet point list of the errors. -func ListFormatFunc(es []error) string { +var ListFormatFunc = func(es []error) string { if len(es) == 1 { return fmt.Sprintf("1 error occurred:\n\t* %s\n\n", es[0]) }