Skip to content

Commit ec00d7b

Browse files
committed
Cleanup. Remove unused functions.
Clarify README.md documentation.
1 parent 065aa64 commit ec00d7b

File tree

10 files changed

+10
-815
lines changed

10 files changed

+10
-815
lines changed

README.md

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
# go-multierror
22

3-
[![Build Status](http://img.shields.io/travis/hashicorp/go-multierror.svg?style=flat-square)][travis]
4-
[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]
5-
6-
[travis]: https://travis-ci.org/hashicorp/go-multierror
7-
[godocs]: https://godoc.org/github.com/hashicorp/go-multierror
8-
93
`go-multierror` is a package for Go that provides a mechanism for
104
representing a list of `error` values as a single `error`.
115

6+
This is a fork of the hashicorp `go-multierror` library. In this
7+
fork, nil error values are handled transparently.
8+
129
This allows a function in Go to return an `error` that might actually
1310
be a list of errors. If the caller knows this, they can unwrap the
1411
list and access the errors. If the caller doesn't know, the error
1512
formats to a nice human-readable format.
1613

17-
`go-multierror` implements the
18-
[errwrap](https://github.com/hashicorp/errwrap) interface so that it can
19-
be used with that library, as well.
20-
2114
## Installation and Docs
2215

23-
Install using `go get github.com/hashicorp/go-multierror`.
24-
25-
Full documentation is available at
26-
http://godoc.org/github.com/hashicorp/go-multierror
16+
Install using `go get github.com/mspiegel/go-multierror`.
2717

2818
## Usage
2919

@@ -38,14 +28,12 @@ if the first argument is nil, a `multierror.Error`, or any other `error`,
3828
the function behaves as you would expect.
3929

4030
```go
41-
var result error
31+
var err, result error
4232

43-
if err := step1(); err != nil {
44-
result = multierror.Append(result, err)
45-
}
46-
if err := step2(); err != nil {
47-
result = multierror.Append(result, err)
48-
}
33+
err = step1()
34+
result = multierror.Append(result, err)
35+
err = step2()
36+
result = multierror.Append(result, err)
4937

5038
return result
5139
```
@@ -79,19 +67,4 @@ if err := something(); err != nil {
7967
// Use merr.Errors
8068
}
8169
}
82-
```
83-
84-
**Returning a multierror only if there are errors**
85-
86-
If you build a `multierror.Error`, you can use the `ErrorOrNil` function
87-
to return an `error` implementation only if there are errors to return:
88-
89-
```go
90-
var result *multierror.Error
91-
92-
// ... accumulate errors here
93-
94-
// Return the `error` only if errors were added to the multierror, otherwise
95-
// return nil since there are no errors.
96-
return result.ErrorOrNil()
97-
```
70+
```

multierror.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ func (e *Error) Error() string {
2020
return fn(e.Errors)
2121
}
2222

23-
// ErrorOrNil returns an error interface if this Error represents
24-
// a list of errors, or returns nil if the list of errors is empty. This
25-
// function is useful at the end of accumulation to make sure that the value
26-
// returned represents the existence of errors.
27-
func (e *Error) ErrorOrNil() error {
28-
if e == nil {
29-
return nil
30-
}
31-
if len(e.Errors) == 0 {
32-
return nil
33-
}
34-
35-
return e
36-
}
37-
3823
func (e *Error) GoString() string {
3924
return fmt.Sprintf("*%#v", *e)
4025
}

multierror_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ func TestErrorError_default(t *testing.T) {
4343
}
4444
}
4545

46-
func TestErrorErrorOrNil(t *testing.T) {
47-
err := new(Error)
48-
if err.ErrorOrNil() != nil {
49-
t.Fatalf("bad: %#v", err.ErrorOrNil())
50-
}
51-
52-
err.Errors = []error{errors.New("foo")}
53-
if v := err.ErrorOrNil(); v == nil {
54-
t.Fatal("should not be nil")
55-
} else if !reflect.DeepEqual(v, err) {
56-
t.Fatalf("bad: %#v", v)
57-
}
58-
}
59-
6046
func TestErrorWrappedErrors(t *testing.T) {
6147
errors := []error{
6248
errors.New("foo"),

prefix.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

prefix_test.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

scripts/deps.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)