https://github.com/yudwig/ermux
ermux is a minimal GO library for multi-error handling.
https://github.com/yudwig/ermux
error-handling go golang library
Last synced: 4 days ago
JSON representation
ermux is a minimal GO library for multi-error handling.
- Host: GitHub
- URL: https://github.com/yudwig/ermux
- Owner: yudwig
- License: mit
- Created: 2021-06-21T02:19:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-21T00:01:20.000Z (over 3 years ago)
- Last Synced: 2025-02-17T11:14:47.370Z (3 months ago)
- Topics: error-handling, go, golang, library
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ermux
ermux is a minimal GO library for multi-error handling.
## Installation
```sh
go get https://github.com/yudwig/ermux
```## Usage
* import
```go
import(
"github.com/yudwig/ermux"
)
```* example
```go
errs := make([]error, 3)
a, errs[0] = exec()
b, errs[1] = exec()
c, errs[2] = exec()if ermux.Some(errs) {
return ermux.First(errs)
}
```## Features
ermux simplify below code.
```go
a, err = exec()
if err != nil {
return err
}
b, err = exec()
if err != nil {
return err
}
c, err = exec()
if err != nil {
return err
}
```## Docs
ermux has only 4 functions.
| I/F | description |
|:------------------------ |:------------------------------------------- |
| **Some** ([]error) bool | Returns true if input has some error(!= nil). |
| **First** ([]error) error | Returns the first error(!= nil) of input. |
| **Last** ([]error) error | Returns the last error(!= nil) of input. |
| **Filter** ([]error) []error | Removes empty(= nil) elements from input error slice.|