This commit is contained in:
2018-12-13 20:33:29 +01:00
parent 7bca21522a
commit d0d888c160
63 changed files with 7546 additions and 2 deletions

5
vendor/github.com/crewjam/errset/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,5 @@
language: go
go:
- 1.5
- 1.6

24
vendor/github.com/crewjam/errset/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>

21
vendor/github.com/crewjam/errset/README.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
errset is a trivial golang package that implements a slice of errors.
[![Build Status](https://travis-ci.org/crewjam/errset.svg?branch=master)](https://travis-ci.org/crewjam/errset)
[![](https://godoc.org/github.com/crewjam/errset?status.png)](http://godoc.org/github.com/crewjam/errset)
The typical go idiom is to return an `error` or a tuple of (thing, `error`) from functions. This works well if a function performs exactly one task, but
when a function does work which can reasonably partially fail, I found myself writing the same code over and over again. For example:
// CommitBatch commits as many things as it can.
func CommitBatch(things []Thing) error {
errs := errset.ErrSet{}
for _, thing := range things {
err := Commit(thing)
if err != nil {
errs = append(errs, err)
}
}
return errs.ReturnValue() // nil if there were no errors
}

48
vendor/github.com/crewjam/errset/errset.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package errset
// ErrSet represents a list of errors.
//
// Example:
//
// errs := ErrSet{}
// for ... {
// if err := DoSomething(i); err != nil {
// errs = append(errs, err)
// }
// }
// return errs.ReturnValue()
//
type ErrSet []error
// ReturnValue returns the ErrSet object if at least one non-nill error is
// present or nil if there are no errors
func (es ErrSet) ReturnValue() error {
rv := ErrSet{}
for _, err := range es {
if err != nil {
rv = append(rv, err)
}
}
if len(rv) == 0 {
return nil
}
return rv
}
// Error implements the error interface. It returns each error in the list
// concatenated together with "; ".
func (es ErrSet) Error() string {
rv := ""
errCount := 0
for _, err := range es {
if err == nil {
continue
}
if errCount != 0 {
rv += "; "
}
rv += err.Error()
errCount++
}
return rv
}