mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-24 21:46:03 +03:00
example of confinement
This commit is contained in:
parent
5c79e57262
commit
f5bf6c88bb
@ -24,4 +24,20 @@ func main() {
|
||||
for num := range handleData {
|
||||
fmt.Println(num)
|
||||
}
|
||||
|
||||
doWork := func(strings <-chan string) <-chan interface{} {
|
||||
completed := make(chan interface{})
|
||||
go func() {
|
||||
defer fmt.Println("doWork exited.")
|
||||
defer close(completed)
|
||||
for s := range strings {
|
||||
// Do something interesting
|
||||
fmt.Println(s, "TTT")
|
||||
}
|
||||
}()
|
||||
return completed
|
||||
}
|
||||
doWork(nil)
|
||||
// Perhaps more work is done here
|
||||
fmt.Println("Done.")
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ func v2() {
|
||||
"https://insights.stackoverflow.com/survey/2017",
|
||||
"https://hackernoon.com/top-10-python-web-frameworks-to-learn-in-2018-b2ebab969d1a",
|
||||
"https://blog.kowalczyk.info/article/1Bkr/3-ways-to-iterate-in-go.html",
|
||||
"A",
|
||||
"B",
|
||||
}
|
||||
for result := range checkStatus(done, urls...) {
|
||||
if result.Error != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user