package main

import (

// waitForTask: You are a manager and you hire a new employee. Your new
// employee doesn't know immediately what they are expected to do and waits for
// you to tell them what to do. You prepare the work and send it to them. The
// amount of time they wait is unknown because you need a guarantee that the
// work your sending is received by the employee.
func waitForTask() {
    ch := make(chan string)

    // var wg sync.WaitGroup
    // wg.Add(1)
    go func() {     // new Employee
        p := <-ch                                    // Channel receive will happen before send(from main)
        fmt.Println("employee : recv'd signal :", p) // do the work
        // wg.Done()

    time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) // prepare the work
    ch <- "paper"                                                // and send it to employee
    fmt.Println("manager : sent signal")

    // wg.Wait() // Wait for the work to complete by employee

func main() {


channel receive(p := <-ch) happens before channel send(is held at ch <- "paper" in main), because this is unbuffered channel


Does main()(manager) need to wait for the work to complete by employee, using sync.WaitGroup?


Does main() need to just ensure that the work is sent to employee?