Standard library / sync/atomic
atomic.Uint64.Or()
Atomically apply bitwise OR and return the previous value (Go 1.23+). Expected stdout: '12\n15\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Uint64) Or(mask uint64) (old uint64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| mask | uint64 | Bit mask used by the atomic operation. |
Return Value
(old uint64)
Previous value before OR.
Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic")
func main() { var x atomic.Uint64; x.Store(12); fmt.Println(x.Or(3)); fmt.Println(x.Load()) }