docs: add doc.go and rewrite exported godoc (#11)#20
Merged
Conversation
Move the package-level documentation into a dedicated doc.go, covering relationship to sync.Map, when-to-use guidance, thread safety, zero-value usability, and a quick-start example. Remove the inline placeholder package comment that landed in #8 purely to satisfy revive.package-comments. Rewrite the godoc on every exported symbol (SyncMap, Load, Store, LoadOrStore, LoadAndDelete, Delete, Range, Len, Map, Keys, Items) to match or improve on sync.Map's stdlib prose. Len, Map, Keys and Items now explicitly call out their O(n) cost and point-in-time approximation under concurrent mutation; LoadAndDelete now states the typed-zero-value-on-miss contract. No behaviour change. No signature change. Coverage unchanged at 100%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves package-level documentation into a dedicated
doc.goand rewrites the godoc on every exported symbol insyncmap.go. The inline placeholder package comment added in #8 (solely to satisfyrevive.package-comments) is removed.Closes #11.
doc.go covers
sync.Map— thin typed wrapper, API parity, same concurrency guarantees.SyncMapvssync.Mapvsmap + sync.RWMutex— with guidance bullets.sync.Map.Per-symbol godoc rewrites (syncmap.go)
Every exported symbol now starts with its name and matches or improves on
sync.Map's stdlib prose:Len,Map,Keys,Items— each explicitly documentsO(n)cost and "point-in-time approximation" under concurrent mutation.LoadAndDelete— explicitly documents the typed-zero-value-on-miss contract (was returningnil/untyped pre-Go-generics wording).Range— preserves stdlib sync.Map Range snapshot wording so readers familiar with stdlib recognise it.Local validation
Agent gates
Out of scope
Test plan