Skip to content

Commit

Permalink
Routine example
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Nov 22, 2023
1 parent 5973ce0 commit c3605f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions examples/errgroup/main.go → examples/group/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ func main() {
return exampleProcessor(ctx)
})

// Wait for errgroup
// Wait for routine group
if err := group.Wait(); err != nil {
fmt.Println(err)
}
fmt.Println("shutting down")
}

func exampleProcessor(ctx context.Context) error {
Expand Down
19 changes: 19 additions & 0 deletions examples/routine/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"

"github.com/sergerad/relax"
)

func main() {
// Start a routine
routine := relax.Go(func() error {
panic(1)
})

// Wait for routine
if err := routine.Wait(); err != nil {
fmt.Println(err)
}
}

0 comments on commit c3605f9

Please sign in to comment.