Skip to content

Commit 6d2d731

Browse files
committed
you're doing great
1 parent 3b3aaa2 commit 6d2d731

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
m := map[int]int{}
9+
m[4] = 7
10+
m[3] = 87
11+
m[72] = 19
12+
13+
ch := make(chan int)
14+
15+
// for closing ch
16+
ch2 := make(chan int)
17+
go func() {
18+
var i int
19+
for n := range ch2 {
20+
i += n
21+
if i == len(m) {
22+
close(ch)
23+
}
24+
}
25+
}()
26+
27+
go func() {
28+
for _, v := range m {
29+
ch <- v
30+
ch2 <- 1
31+
}
32+
}()
33+
34+
for v := range ch {
35+
fmt.Println(v)
36+
}
37+
38+
// good housekeeping
39+
close(ch2)
40+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# New Code
2+
3+
These files were added into this repo after the training was recorded.
4+
5+
There are no lectures associated with these files. However, please peruse them and enjoy them!

0 commit comments

Comments
 (0)