Skip to content

Instantly share code, notes, and snippets.

@mpenick
Last active January 24, 2024 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpenick/83ac6b119a5cf6da90e3cfc011d50b11 to your computer and use it in GitHub Desktop.
Save mpenick/83ac6b119a5cf6da90e3cfc011d50b11 to your computer and use it in GitHub Desktop.
func main() {
defer func() {
if r := recover(); r != nil {
panic("never called")
}
}()
// fatal error: concurrent map writes
m := make(map[int]int)
for i := 0; i < 100; i++ {
go func(i int) {
m[i] = i
}(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment