Skip to content

Commit

Permalink
Fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Nov 8, 2023
1 parent 6c274e7 commit f0542d2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ If you have multiple, long running processes to run in your program, you can use
g, ctx := errgroup.WithContext(mainCtx)
```
Launch your goroutines and make sure to defer `relax.Recover(cancel)` so that any panics do not get in the way of graceful shutdown of the program.
Launch your goroutines and make sure to `defer relax.Recover(cancel)` so that any panics do not get in the way of graceful shutdown of the program.
```Go
g.Go(func() error {
defer relax.Recover(cancel)
return myLongRunningProcess(ctx)
})
```
You can use `relax.Recover(cancel)` for any sub-goroutine that you launch in your program at all. If you launch goroutines without deferring
Finally, in the main goroutine, make sure to wait for the error group:
```Go
Expand Down

0 comments on commit f0542d2

Please sign in to comment.