---
source: https://iinventedlight.com/library/notes/go-sync-map.md
title: "sync.Map: a map safe for concurrent goroutines"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/map.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-sync-map"
tags: [go, sync, map, concurrency, goroutines]
client: Librarian
sources:
  - id: S1
    title: "sync package reference"
    publisher: Go
    url: https://pkg.go.dev/sync
    accessed: 2026-11-23
    license: "BSD-3-Clause"
  - id: S2
    title: "sync/map.go source"
    publisher: Go
    url: https://go.dev/src/sync/map.go
    accessed: 2026-11-23
    license: "BSD-3-Clause"
---
# sync.Map: a map safe for concurrent goroutines
**Answer:** Map is safe for concurrent use by multiple goroutines. Loads, stores, and deletes run in amortized constant time. A Map must not be copied after first use. The zero Map is empty and ready for use.

## When to use Map

Map is like a Go map of any to any, and multiple goroutines may use it concurrently without additional locking or coordination.

The type is specialized. For better type safety, most code should keep a plain Go map and add separate locking or coordination.

A better fit is a key written once and then read many times, as in a cache that only grows, or several goroutines that read, write, and overwrite disjoint sets of keys.

Those patterns can reduce lock contention versus pairing a Go map with a Mutex or RWMutex.

## Methods

Load returns the value stored for a key, or nil if no value is present. The ok result indicates whether the value was found.

Store sets the value for a key.

Delete deletes the value for a key, and does nothing when the key is not in the map.

LoadOrStore returns the existing value for a present key. Otherwise it stores the given value and returns that.

Range calls a function sequentially for each key and value present.

Clear deletes all the entries, resulting in an empty Map.

## See also

- [go-sync-mutex](https://iinventedlight.com/library/notes/go-sync-mutex/)
- [go-sync-waitgroup](https://iinventedlight.com/library/notes/go-sync-waitgroup/)
- [go-maps](https://iinventedlight.com/library/notes/go-maps/)

## Claims

- id: C1
  claim: A Map is safe for concurrent use by multiple goroutines without additional locking.
  source: S1
  evidence: "safe for concurrent use by multiple goroutines without additional locking"

- id: C2
  claim: Loads, stores, and deletes run in amortized constant time.
  source: S1
  evidence: "Loads, stores, and deletes run in amortized constant time"

- id: C3
  claim: The zero Map is empty and ready for use.
  source: S2
  evidence: "The zero Map is empty and ready for use"

- id: C4
  claim: A Map must not be copied after first use.
  source: S2
  evidence: "A Map must not be copied after first use"

- id: C5
  claim: Load returns the stored value, or nil if none is present.
  source: S1
  evidence: "or nil if no value is present"

## Sources

- [S1] sync package reference. Go. https://pkg.go.dev/sync . License: BSD-3-Clause. Accessed 2026-11-23.

- [S2] sync/map.go source. Go. https://go.dev/src/sync/map.go . License: BSD-3-Clause. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/map.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
