1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

golangでgoroutineに無名関数を使う

Posted at

goroutineを使う際に無名関数を使う方がwaitするのが簡単とのことで
備忘録

main.go

var wg sync.WaitGroup
wg.Add(1)
go func() {
   defer wg.Done()
   //回したい関数
}()
wg.Wait()

回したい関数に&wgを渡すという記事を最初に読み、そうしていたけど
こっちのが簡単だった。(その後調べたらこの書き方の記事のがやはり多かった)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?