bogus

command
v0.0.0-...-434faa1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

From Racy to Non-Racy

Run the bad example first.

go run --race playground/bogus/bogus.go -bogus
==================
WARNING: DATA RACE
Read at 0x00c0000a0220 by goroutine 17: bogus.go:37 +0x85
Previous write at 0x00c0000a0220 by goroutine 16: bogus.go:25 +0xb6
...
==================
read: name = 9
read: name = 3
read: name = 3
read: name = 5
read: name = 6
read: name = 6
read: name = 4
read: name = 7
read: name = 7
Found 1 data race(s)
exit status 66

Race conditions are a hint that concurrent reads and writes are not proteced with sync primitives.

Now run the good example:

go run --race playground/bogus/bogus.go
read: name = 9
read: name = 3
read: name = 3
read: name = 5
read: name = 6
read: name = 6
read: name = 4
read: name = 7
read: name = 7
read: name = 2

All good!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL