diff --git a/version b/version index 3f684d2d..cc6c9a49 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.3.4 +2.3.5 diff --git a/waitgroup.go b/waitgroup.go index eb4cf2d7..1daa5c26 100644 --- a/waitgroup.go +++ b/waitgroup.go @@ -44,14 +44,8 @@ func (wg *WaitGroup) Run(callBack func(interface{}) error, data interface{}) { func (wg *WaitGroup) Go(cb func()) { wg.wg.Add(1) go func() { - err := cb - if err == nil { - wg.wg.Done() - return - } - wg.mutex.Lock() + cb() wg.wg.Done() - wg.mutex.Unlock() }() } diff --git a/waitgroup_test.go b/waitgroup_test.go index 671cc694..a74a46d1 100644 --- a/waitgroup_test.go +++ b/waitgroup_test.go @@ -61,17 +61,31 @@ func (s *WaitGroupTestSuite) TestRun() { func (s *WaitGroupTestSuite) TestGo() { var wg holster.WaitGroup + result := make(chan struct{}) wg.Go(func() { // Do some long running thing time.Sleep(time.Nanosecond * 500) + result <- struct{}{} }) wg.Go(func() { // Do some long running thing time.Sleep(time.Nanosecond * 50) + result <- struct{}{} }) +OUT: + for i := 0; i < 2; { + select { + case <-result: + i++ + case <-time.After(time.Second): + s.Fail("waited to long for Go() to run") + break OUT + } + } + errs := wg.Wait() s.Nil(errs) }