Skip to content

Commit 07d0027

Browse files
kate-osbornpleshakov
authored andcommitted
Add caveat to protecting maps and slices
Co-authored-by: Michael Pleshakov <[email protected]>
1 parent 41dd023 commit 07d0027

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/developer/go-style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Below are some general guidelines to follow for writing concurrent code:
343343
- **Avoid buffered channels**: Use unbuffered channels unless there is a very good reason for using a buffered channel.
344344
Unbuffered channels provide strong synchronization guarantees. Buffered channels are asynchronous and will not block
345345
unless the channel is full. Buffered channels can also be slower than unbuffered channels.
346-
- **Protect maps and slices**: Maps and slices cannot be accessed concurrently without locking. Doing so can lead to
346+
- **Protect maps and slices**: Maps and slices cannot be accessed concurrently (when at least one goroutine is writing) without locking. Doing so can lead to
347347
data races.
348348
- **Never copy sync types**: see [above section](#do-not-copy-sync-entities).
349349
- **Choose primitives or channels based on use case**: In general, the Go language writers tell us to prefer channels

0 commit comments

Comments
 (0)