Standard library / sync/atomic

atomic.Value

Store and load a value of a consistent concrete type atomically. A zero Value loads nil; storing nil or changing the concrete type panics. Do not copy after use. Expected stdout: 'true\nready\n'.

Formal Syntax & Structure

go syntaxgo
type Value struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() {  var v atomic.Value  fmt.Println(v.Load() == nil)  v.Store("ready")  fmt.Println(v.Load())}
Go Reference