Standard library / sync/atomic

atomic.Value.Load()

Load the current value, or nil before the first Store. Type-assert when needed. Expected stdout: 'ready\n'.

Formal Syntax & Structure

go syntaxgo
func (v *Value) Load() (val any)

Return Value

(val any)

Stored value or nil.

Working Example

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