Skip to content

Commit 8cc9cb0

Browse files
committed
chore: bring back unused util.go file as removing it is a breaking change
1 parent 1996ec8 commit 8cc9cb0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

util.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,43 @@ package migrate
33
import (
44
"fmt"
55
nurl "net/url"
6+
"strings"
67
)
78

9+
// TODO: This file is not in use anymore inside this project.
10+
// Remove it in the v5 release.
11+
12+
// MultiError holds multiple errors.
13+
//
14+
// Deprecated: Use github.com/hashicorp/go-multierror instead
15+
type MultiError struct {
16+
Errs []error
17+
}
18+
19+
// NewMultiError returns an error type holding multiple errors.
20+
//
21+
// Deprecated: Use github.com/hashicorp/go-multierror instead
22+
func NewMultiError(errs ...error) MultiError {
23+
compactErrs := make([]error, 0)
24+
for _, e := range errs {
25+
if e != nil {
26+
compactErrs = append(compactErrs, e)
27+
}
28+
}
29+
return MultiError{compactErrs}
30+
}
31+
32+
// Error implements error. Multiple errors are concatenated with 'and's.
33+
func (m MultiError) Error() string {
34+
var strs = make([]string, 0)
35+
for _, e := range m.Errs {
36+
if len(e.Error()) > 0 {
37+
strs = append(strs, e.Error())
38+
}
39+
}
40+
return strings.Join(strs, " and ")
41+
}
42+
843
// suint safely converts int to uint
944
// see https://goo.gl/wEcqof
1045
// see https://goo.gl/pai7Dr

0 commit comments

Comments
 (0)