How to pass a channel to a function as a parameter?
go
Solution
`done(&signal)` is called synchronously. Maybe what you wanted to do is to call it asynchronously?
to do so, put the keyword `go` in front of the function call
go done(&signal)
The main thread will block until the done function writes to the channel. And the done method will block on writing to the channel until the main thread reads the channel.
Problem
I made two attempts to pass a channel to a function as a parameter, but they both fail (deadlock): Attempt 1: ``` func done(signal *chan bool) { *signal <- true } func main() { signal := make(chan bool) done(&signal) <-signal fmt.Println("completed") } ``` Attempt 2: ``` func done(signal chan bool) { signal <- true } func main() { signal := make(chan bool) done(signal) <-signal fmt.Println("completed") } ``` Well I am out of ideas. What should be the proper way to pass the channel to the function?