Documentation ¶
Index ¶
- Variables
- func CombineErrors(errs ...error) error
- func EnvVarBoolean(value string) bool
- func FilterOut(err error, fns ...Matcher) error
- func Reduce(err error) error
- func StringArrayIndex(array []string, value string) int
- func StringMatchesAny(text string, includes, excludes []string) bool
- func StringMatchesPattern(text, pattern string) bool
- type Aggregate
- type Matcher
- type MessageCountMap
Constants ¶
This section is empty.
Variables ¶
var ( // ColorInfo returns a new function that returns info-colorized (green) strings for the // given arguments with fmt.Sprint(). ColorInfo = color.New(color.FgGreen).SprintFunc() )
Functions ¶
func CombineErrors ¶
CombineErrors combines the non null errors into a single error or returns null
func EnvVarBoolean ¶
func FilterOut ¶
FilterOut removes all errors that match any of the matchers from the input error. If the input is a singular error, only that error is tested. If the input implements the Aggregate interface, the list of errors will be processed recursively.
This can be used, for example, to remove known-OK errors (such as io.EOF or os.PathNotFound) from a list of errors.
func Reduce ¶
Reduce will return err or, if err is an Aggregate and only has one item, the first item in the aggregate.
func StringArrayIndex ¶ added in v0.0.4
StringArrayIndex returns the index in the slice which equals the given value
func StringMatchesAny ¶
StringMatchesAny returns true if the given text matches the includes/excludes lists
func StringMatchesPattern ¶
StringMatchesPattern returns true if the given text matches the includes/excludes lists
Types ¶
type Aggregate ¶
Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.
func AggregateGoroutines ¶
AggregateGoroutines runs the provided functions in parallel, stuffing all non-nil errors into the returned Aggregate. Returns nil if all the functions complete successfully.
func CreateAggregateFromMessageCountMap ¶
func CreateAggregateFromMessageCountMap(m MessageCountMap) Aggregate
CreateAggregateFromMessageCountMap converts MessageCountMap Aggregate
func Flatten ¶
Flatten takes an Aggregate, which may hold other Aggregates in arbitrary nesting, and flattens them all into a single Aggregate, recursively.
func NewAggregate ¶
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil. It will check if any of the element of input error list is nil, to avoid nil pointer panic when call Error().
type MessageCountMap ¶
MessageCountMap contains occurrence for each error message.