summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/wiggin77
diff options
context:
space:
mode:
authorWim <wim@42.be>2021-10-16 23:11:32 +0200
committerWim <wim@42.be>2021-10-16 23:23:24 +0200
commit20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8 (patch)
tree230edca06449a8d1755f08aabf45a03e07e6f17c /vendor/github.com/wiggin77
parent57fce93af7f64f025cec6f3ed6088163086bc9fe (diff)
downloadmatterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.tar.gz
matterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.tar.bz2
matterbridge-msglm-20f6c05ec50739d31f4dbe9fde0d223f2c43f6e8.zip
Update vendor
Diffstat (limited to 'vendor/github.com/wiggin77')
-rw-r--r--vendor/github.com/wiggin77/merror/.travis.yml5
-rw-r--r--vendor/github.com/wiggin77/merror/README.md6
-rw-r--r--vendor/github.com/wiggin77/merror/go.mod4
-rw-r--r--vendor/github.com/wiggin77/merror/go.sum10
-rw-r--r--vendor/github.com/wiggin77/merror/merror.go41
5 files changed, 61 insertions, 5 deletions
diff --git a/vendor/github.com/wiggin77/merror/.travis.yml b/vendor/github.com/wiggin77/merror/.travis.yml
new file mode 100644
index 00000000..9899b387
--- /dev/null
+++ b/vendor/github.com/wiggin77/merror/.travis.yml
@@ -0,0 +1,5 @@
+language: go
+sudo: false
+before_script:
+ - go vet ./...
+ \ No newline at end of file
diff --git a/vendor/github.com/wiggin77/merror/README.md b/vendor/github.com/wiggin77/merror/README.md
index 8a31687f..964c7ac8 100644
--- a/vendor/github.com/wiggin77/merror/README.md
+++ b/vendor/github.com/wiggin77/merror/README.md
@@ -1,2 +1,6 @@
# merror
-Multiple Error aggregator for Golang.
+
+[![GoDoc](https://godoc.org/github.com/wiggin77/merror?status.svg)](https://godoc.org/github.com/wiggin77/merror)
+[![Build Status](https://travis-ci.org/wiggin77/merror.svg?branch=master)](https://travis-ci.org/wiggin77/merror)
+
+Multiple Error aggregator for Go.
diff --git a/vendor/github.com/wiggin77/merror/go.mod b/vendor/github.com/wiggin77/merror/go.mod
index 44982f78..ba207ace 100644
--- a/vendor/github.com/wiggin77/merror/go.mod
+++ b/vendor/github.com/wiggin77/merror/go.mod
@@ -1 +1,5 @@
module github.com/wiggin77/merror
+
+go 1.15
+
+require github.com/stretchr/testify v1.6.1
diff --git a/vendor/github.com/wiggin77/merror/go.sum b/vendor/github.com/wiggin77/merror/go.sum
new file mode 100644
index 00000000..56d62e7c
--- /dev/null
+++ b/vendor/github.com/wiggin77/merror/go.sum
@@ -0,0 +1,10 @@
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/vendor/github.com/wiggin77/merror/merror.go b/vendor/github.com/wiggin77/merror/merror.go
index 01f19913..def75354 100644
--- a/vendor/github.com/wiggin77/merror/merror.go
+++ b/vendor/github.com/wiggin77/merror/merror.go
@@ -1,9 +1,13 @@
package merror
+import "sync"
+
// MError represents zero or more errors that can be
// accumulated via the `Append` method.
type MError struct {
- cap int
+ cap int
+
+ mux sync.RWMutex
errors []error
overflow int
formatter FormatterFunc
@@ -34,6 +38,10 @@ func (me *MError) Append(err error) {
if err == nil {
return
}
+
+ me.mux.Lock()
+ defer me.mux.Unlock()
+
if me.cap > 0 && len(me.errors) >= me.cap {
me.overflow++
} else {
@@ -41,26 +49,41 @@ func (me *MError) Append(err error) {
}
}
-// Errors returns an array of the `error` instances that have been
+// Errors returns a slice of the `error` instances that have been
// appended to this `MError`.
func (me *MError) Errors() []error {
- return me.errors
+ me.mux.RLock()
+ defer me.mux.RUnlock()
+
+ errs := make([]error, len(me.errors))
+ copy(errs, me.errors)
+
+ return errs
}
// Len returns the number of errors that have been appended.
func (me *MError) Len() int {
+ me.mux.RLock()
+ defer me.mux.RUnlock()
+
return len(me.errors)
}
// Overflow returns the number of errors that have been truncated
// because maximum capacity was exceeded.
func (me *MError) Overflow() int {
+ me.mux.RLock()
+ defer me.mux.RUnlock()
+
return me.overflow
}
// SetFormatter sets the `FormatterFunc` to be used when `Error` is
// called. The previous `FormatterFunc` is returned.
func (me *MError) SetFormatter(f FormatterFunc) (old FormatterFunc) {
+ me.mux.Lock()
+ defer me.mux.Unlock()
+
old = me.formatter
me.formatter = f
return
@@ -69,7 +92,14 @@ func (me *MError) SetFormatter(f FormatterFunc) (old FormatterFunc) {
// ErrorOrNil returns nil if this `MError` contains no errors,
// otherwise this `MError` is returned.
func (me *MError) ErrorOrNil() error {
- if me == nil || len(me.errors) == 0 {
+ if me == nil {
+ return nil
+ }
+
+ me.mux.RLock()
+ defer me.mux.RUnlock()
+
+ if len(me.errors) == 0 {
return nil
}
return me
@@ -79,6 +109,9 @@ func (me *MError) ErrorOrNil() error {
// The output format depends on the `Formatter` set for this
// merror instance, or the global formatter if none set.
func (me *MError) Error() string {
+ me.mux.RLock()
+ defer me.mux.RUnlock()
+
f := me.formatter
if f == nil {
f = GlobalFormatter