Created
November 22, 2023 12:16
-
-
Save yumed15/7f0b4ed3c7f7992c87e7d3d1ca068148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count int | |
increment := func() {count++} | |
decrement := func() {count--} | |
var once sync.Once | |
once.Do(increment) | |
once.Do(decrement) | |
fmt.Println(count) // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment