✨ Refactor: Convert WaitErr to an interface and add New constructor
This commit is contained in:
parent
a68fc26481
commit
edc34062e9
4 changed files with 47 additions and 42 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue