MCPcopy
hub / github.com/hoanhan101/ultimate-go / main

Function main

go/concurrency/channel_4.go:20–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18var wg sync.WaitGroup
19
20func main() {
21 // Create an unbuffered channel.
22 track := make(chan int)
23
24 // Add a count of one for the last runner.
25 // We only add one because all we care about is the last runner in the race telling us that he
26 // is done.
27 wg.Add(1)
28
29 // Create a first runner to his mark.
30 go Runner(track)
31
32 // The main Goroutine start the race (shoot the gun).
33 // At this moment, we know that on the other side, a Goroutine is performing a receive.
34 track <- 1
35
36 // Wait for the race to finish.
37 wg.Wait()
38}
39
40// Runner simulates a person running in the relay race.
41// This Runner doesn't have a loop because it's gonna do everything from the beginning to end and

Callers

nothing calls this directly

Calls 3

RunnerFunction · 0.85
AddMethod · 0.80
WaitMethod · 0.65

Tested by

no test coverage detected