Standard library / sync/atomic
atomic.Uint64.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 *Uint64) Store(val uint64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| val | uint64 | Value to store; context values should be request-scoped. |
Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic")
func main() { var x atomic.Uint64; x.Store(12); x.Store(15); fmt.Println(x.Load()) }