Standard library / sync
sync.Map.Store()
Associate a comparable key with a value, replacing any previous entry. Expected stdout: '2\n'.
Formal Syntax & Structure
go syntaxgo
func (m *Map) Store(key, value any)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | any | Comparable map key, or a package-specific comparable context key. |
| value | any | Value associated with the key. |
Working Example
Example Snippetgo
package main
import ( "fmt" "sync")
func main() { var m sync.Map; m.Store("a", 1); m.Store("a", 2); v, _ := m.Load("a"); fmt.Println(v) }