---
title: "Discussion on \"Go Cheatsheet - WaitGroup / Mutex / Atomic\" | Hashnode"
description: "Discussion on \"Go Cheatsheet - WaitGroup / Mutex / Atomic\". Concurrency\nWaitGroup\nvar wg sync.WaitGroup\nfor i := 1; i <= 5; i++ {\n    wg.Add(1)\n    go func(num int) {\n        defer wg.Done()\n    }(i)\n}\nwg.Wait()\n\nMutex\nimport \"sync\"\n\nvar mu sync.Mutex\nmu.Lock()\n// do some operation\nmu.Unlock()\n\nUse atomic to ..."
url: "https://hashnode.com/posts/go-cheatsheet-waitgroup-mutex-atomic/6080e324eb2bd30d2d22e5ad"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Go Cheatsheet - WaitGroup / Mutex / Atomic](https://hn.0xbf.me/go-cheatsheet-waitgroup-mutex-atomic?utm_source=hashnode&utm_medium=feed)

Concurrency WaitGroup var wg sync.WaitGroup for i := 1; i <= 5; i++ { wg.Add(1) go func(num int) { defer wg.Done() }(i) } wg.Wait() Mutex import "sync" var mu sync.Mutex mu.Lock() // do some operation mu.Unlock() Use atomic to ...

Apr 22, 2021 · 1 min read · hn.0xbf.me  
Read the article

-   [#go](https://hashnode.com/tag/go)

## Written by

[0xBF](https://hashnode.com/@0xbf)

@0xbf

  
[View profile](https://hashnode.com/@0xbf)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
