Go Documentation 輪読会 #28
前回: Go Documentation 輪読会 #27
Scrapboxへの参加リンク
こちら
開催概要
Slack
Gophers Slack の doc-reading-ja チャンネルを使います
Connpass: https://gospecreading.connpass.com/
Google Meet: ConnpassにURLを記載しています
タイムテーブル
19:10 ~ 輪読開始
20:00 ~ 10分休憩
20:10 ~ 再開
21:00 終了
今日読むもの
https://github.com/golang/go/issues/61405
https://research.swtch.com/coro
読んでおくといいかも
https://github.com/koron/techdocs/blob/main/coroutines-for-go/memo.md
本日のメモ
yieldを保持して、後から呼ぶパターン
https://gotipplay.golang.org/p/VGyOakKuWft
別のgoroutineでyieldを呼ぶパターン
https://gotipplay.golang.org/p/sov6N0nKN8w
このパターンでは、すぐにints関数がreturnしてしまうため、loopから離脱する
https://gotipplay.golang.org/p/Ir4b1iLeHfG
このパターンでは、select {} でblockするため、goroutineの実行結果を待つことが出来ている
iterator functionの中でdeferするパターン
iterator function内でfileをopenし、defer Closeする
https://gotipplay.golang.org/p/Rz8hRani-wC
iterator が別goroutineで動いて、channelで値を送るパターン
https://gotipplay.golang.org/p/NAz1oGcBvmT
deferをさらに呼ぶパターン
https://gotipplay.golang.org/p/ASuKui05djJ