Skip to content

Commit deb79ee

Browse files
committed
feat: Issue: Loop Struct Slice update
1 parent 18481eb commit deb79ee

5 files changed

Lines changed: 88 additions & 98 deletions

File tree

examples/interview/interview.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"sync"
6+
)
7+
8+
// Any error? What's wrong here? Any optimizations?
9+
func concurrency() {
10+
ch := make(chan *int, 4)
11+
array := []int{1, 2, 3, 4}
12+
wg := sync.WaitGroup{}
13+
wg.Add(1)
14+
go func() {
15+
for _, value := range array {
16+
ch <- &value
17+
}
18+
}()
19+
20+
go func() {
21+
for value := range ch {
22+
fmt.Println(*value)
23+
}
24+
wg.Done()
25+
}()
26+
wg.Wait()
27+
}
28+
29+
func main() {
30+
concurrency()
31+
}

examples/interview/notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Interview
2+
#### Question
3+
1.

examples/interview/t.ts

Whitespace-only changes.

public/issue-loop-struct-slice

Lines changed: 27 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/issue-loop-struct-slice.html

Lines changed: 27 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)