Bump github.com/mitchellh/mapstructure

This commit is contained in:
Tomoya Usami
2017-04-10 10:37:29 +09:00
parent ca1f844bc8
commit 122ed986cb
5 changed files with 273 additions and 59 deletions

View File

@@ -1,7 +1,9 @@
package mapstructure
import (
"errors"
"fmt"
"sort"
"strings"
)
@@ -17,11 +19,27 @@ func (e *Error) Error() string {
points[i] = fmt.Sprintf("* %s", err)
}
sort.Strings(points)
return fmt.Sprintf(
"%d error(s) decoding:\n\n%s",
len(e.Errors), strings.Join(points, "\n"))
}
// WrappedErrors implements the errwrap.Wrapper interface to make this
// return value more useful with the errwrap and go-multierror libraries.
func (e *Error) WrappedErrors() []error {
if e == nil {
return nil
}
result := make([]error, len(e.Errors))
for i, e := range e.Errors {
result[i] = errors.New(e)
}
return result
}
func appendErrors(errors []string, err error) []string {
switch e := err.(type) {
case *Error: