forked from ardanlabs/gotraining
/
template1.go
42 lines (28 loc) · 980 Bytes
/
template1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// Write a program where two goroutines pass an integer back and forth
// ten times. Display when each goroutine receives the integer. Increment
// the integer with each pass. Once the integer equals ten, terminate
// the program cleanly.
package main
// Add imports.
func main() {
// Create an unbuffered channel.
// Create the WaitGroup and add a count
// of two, one for each goroutine.
// Launch the goroutine and handle Done.
// Launch the goroutine and handle Done.
// Send a value to start the counting.
// Wait for the program to finish.
}
// goroutine simulates sharing a value.
func goroutine( /* parameters */ ) {
for {
// Wait for the value to be sent.
// If the channel was closed, return.
// Display the value.
// Terminate when the value is 10.
// Increment the value and send it
// over the channel.
}
}