Refactor: Convert WaitErr to an interface and add New constructor

This commit is contained in:
Dan Jones 2025-11-14 14:04:51 -06:00
commit edc34062e9
4 changed files with 47 additions and 42 deletions

View file

@ -9,8 +9,7 @@ import (
)
func Example() {
we := new(waiterr.WaitErr)
we := waiterr.New()
we.Go(func() error {
time.Sleep(100 * time.Millisecond)
fmt.Println("Goroutine 1 finished")
@ -43,7 +42,7 @@ func Example() {
}
func ExampleWaitErr_WaitForError() {
we := new(waiterr.WaitErr)
we := waiterr.New()
we.Go(func() error {
time.Sleep(100 * time.Millisecond)
return errors.New("first error from we")
@ -63,7 +62,7 @@ func ExampleWaitErr_WaitForError() {
}
func ExampleWaitErr_Unwrap() {
we := new(waiterr.WaitErr)
we := waiterr.New()
we.Go(func() error {
time.Sleep(100 * time.Millisecond)
return errors.New("first error from we")