Golang Mistakes that I Encounter
Irregular updates Go Gotcha: math/rand Thread Safety Isn’t Universal Ran into a subtle trap with Go’s math/rand package regarding concurrency. It’s easy to assume all random generation is thread-safe, but that’s not quite right. The Key Difference: rand.Intn() (Package Level): Thread-safe! Uses a global source with an internal mutex. Good for most concurrent uses. myRand.Intn() (Method on *rand.Rand): NOT thread-safe by default! If you create your own *rand.Rand instance (myRand) and share it between goroutines, calling its methods concurrently without your own locking will cause data races. Example I Encountered: ...