Standard library / sync/atomic
atomic.Bool
Atomic boolean flag, initially false. Do not copy after first use. Expected stdout: 'false\ntrue\n'.
Formal Syntax & Structure
go syntaxgo
type Bool struct {}Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic")
func main() { var x atomic.Bool; fmt.Println(x.Load()); x.Store(true); fmt.Println(x.Load()) }