Skip to content

Commit

Permalink
add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Kossovich committed Aug 4, 2023
1 parent d19760d commit 5df7f0d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,25 @@ p := pipe.Range(10, 20, 2).Map(func(x int) int { return x * x }).Do()
p := pipe.Repeat("hello", 5).Map(strings.ToUpper).Do()
// p will be ["HELLO", "HELLO", "HELLO", "HELLO", "HELLO"]
```
Here is an example how you can handle multiple function returning error call this way:

```go
func foo() error {
// <...>
return nil
}

errs := pipe.Map(
pipe.Repeat(foo, 50),
func(f func() error) error { return f() },
).Do()

for _, e := range errs {
if e != nil {
log.Err(e)
}
}
```

### Example using `Cycle` and `Filter`:

Expand Down

0 comments on commit 5df7f0d

Please sign in to comment.