From 57b41ad766b3c4505672c12f058f10c7a132dd5b Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sat, 24 Jun 2023 00:34:57 +0200 Subject: feat: Remove unnecessary function --- pkg/worker/worker.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pkg/worker/worker.go') diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go index 18cc0e2..359384a 100644 --- a/pkg/worker/worker.go +++ b/pkg/worker/worker.go @@ -20,7 +20,6 @@ type ( WorkerPool struct { workers []*Work - wg sync.WaitGroup } ) @@ -36,10 +35,13 @@ func (self *WorkerPool) AddWorker(name string, worker Worker) { } func (self *WorkerPool) Start(ctx context.Context) { - self.wg.Add(len(self.workers)) + var wg sync.WaitGroup + + wg.Add(len(self.workers)) + for _, w := range self.workers { go func(w *Work) { - defer self.wg.Done() + defer wg.Done() if err := w.Worker.Start(ctx); err != nil && !errors.Is(err, context.Canceled) { fmt.Println("Processes finished, error", w.Name, err.Error()) } else { @@ -47,8 +49,6 @@ func (self *WorkerPool) Start(ctx context.Context) { } }(w) } -} -func (self *WorkerPool) Wait() { - self.wg.Wait() + wg.Wait() } -- cgit v1.2.3