diff --git a/examples/errgroup/main.go b/examples/group/main.go similarity index 91% rename from examples/errgroup/main.go rename to examples/group/main.go index 665c08c..49f0adc 100644 --- a/examples/errgroup/main.go +++ b/examples/group/main.go @@ -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 { diff --git a/examples/routine/main.go b/examples/routine/main.go new file mode 100644 index 0000000..8148389 --- /dev/null +++ b/examples/routine/main.go @@ -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) + } +}