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