diff --git a/example-go-channel/sendFunction.go b/example-go-channel/sendFunction.go index 9f6e43f..269b129 100644 --- a/example-go-channel/sendFunction.go +++ b/example-go-channel/sendFunction.go @@ -11,6 +11,7 @@ import ( type funcWait struct { f func() wgF sync.WaitGroup + val int err error res int } @@ -27,7 +28,7 @@ func generateNumbers(total int, ch chan<- *funcWait, af *funcWait) { log.Println("generateNumbers() END total =", total) } -func andlabsGoroutine(ch <-chan *funcWait, wgF *sync.WaitGroup) { +func andlabsGoroutine(ch <-chan *funcWait, wg *sync.WaitGroup) { defer wg.Done() log.Println("andlabsGoroutine() START") @@ -39,7 +40,6 @@ func andlabsGoroutine(ch <-chan *funcWait, wgF *sync.WaitGroup) { } func main() { - functionChan = make(chan *funcWait) // syntax to get the return values from a channel @@ -49,12 +49,13 @@ func main() { wg.Add(1) go andlabsGoroutine(functionChan, &wg) - afunc.wgF = wg + // afunc.wgF = wg afunc.f = func() { - log.Println("\tGOT INSIDE: running f() from inside the structure & inside the wait group goroutine") + log.Println("\tGOT INSIDE: running f() from inside the structure & inside the wait group goroutine", afunc.val) } for idx := 1; idx <= 10; idx++ { + afunc.val = idx * 20 generateNumbers(idx, functionChan, &afunc) }