Standard library / sync/atomic

atomic.Bool.Store()

Set the boolean atomically. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Bool) Store(val bool)

Parameters & Attributes

NameTypeDescription
valboolValue to store; context values should be request-scoped.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() { var x atomic.Bool; x.Store(true); fmt.Println(x.Load()) }
Go Reference