-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
good first issueThese are great first issues. If you are looking for a place to start, start here!These are great first issues. If you are looking for a place to start, start here!
Description
Summary
We currently have a linter rule that blocks usage of sync/atomic and forces us to use go.uber.go/atomic instead. This rule was originally added because sync/atomic required atomic operations on primitive types, which was considered error-prone.
However, since Go 1.19, the standard library sync/atomic package now includes typed wrappers (e.g., atomic.Uint32, atomic.Int64, atomic.Bool, etc.) that provide the same safety guarantees as go.uber.go/atomic. This makes the uber package redundant.
Context
Prometheus is also making this transition:
- Issue: replace uber atomic with stdlib atomic types prometheus/prometheus#14866
- PR: refactor: replace go.uber.org/atomic with sync/atomic across codebase prometheus/prometheus#18009
Proposed Changes
- Remove the linter rule that blocks
sync/atomic - Migrate all
go.uber.go/atomicusage to the standard librarysync/atomictyped wrappers - Configure a linter rule to block the old-style atomic functions that operate on primitive types (e.g.,
atomic.AddInt64,atomic.LoadUint32) to ensure we only use the new typed wrappers and avoid accidental misuse
This approach gives us:
- Fewer external dependencies
- Alignment with the broader Go ecosystem
- Same safety guarantees we had with uber/atomic
References
- Go 1.19 release notes on atomic types: https://tip.golang.org/doc/go1.19#atomic_types
sync/atomicpackage docs: https://pkg.go.dev/sync/atomic
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueThese are great first issues. If you are looking for a place to start, start here!These are great first issues. If you are looking for a place to start, start here!