Standard library / sync/atomic
atomic.Uint32.Store()
Atomically replace the current value. Other shared data needs its own synchronization protocol. Expected stdout: '15\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Uint32) Store(val uint32)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| val | uint32 | Value to store; context values should be request-scoped. |
Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic")
func main() { var x atomic.Uint32; x.Store(12); x.Store(15); fmt.Println(x.Load()) }