Standard library / sync/atomic

atomic.Int32

A typed atomic int32 with a usable zero value. Do not copy after first use. Prefer typed atomics to raw pointer functions for new code. Expected stdout: '0\n3\n'.

Formal Syntax & Structure

go syntaxgo
type Int32 struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() { var x atomic.Int32; fmt.Println(x.Load()); x.Add(3); fmt.Println(x.Load()) }
Go Reference