uber-go / uber-go/atomic

Remove methods duplicated in `go1.19` `sync/atomic`

Open
#119 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.5k
Forks
116
Avg merge
7d 10h
Merged PRs (30d)
4

Description

Since the go1.19 update, there are lots of duplicate functionality between this package and sync/atomic. This duplication is currently needed because go1.18 is still supported.

sync/atomic has the following types that are duplicated here:

  • Bool
  • Int32
  • Int64
  • Pointer[T]
  • Uint32
  • Uint64
  • Uintptr

All types in sync/atomic have the following methods:

  • CompareAndSwap
  • Load
  • Store
  • Swap

Integer-like types have the following, in addition to the above:

  • Add

But there is still some functionality in here go.uber.org/atomic that is not there in sync/atomic.

All thing considered, after go1.18 becomes unsupported, we could do the following:

  • Update gen-atomicint to embed sync/atomic types. Only the following additional methods
    need to be kept.
    - CAS (Deprecated)
    - Dec
    - Inc
    - Sub
    - String
    - MarshallJSON
    - UnmarshallJSON
  • Update Bool to embed sync/atomic type. Only the following additional methods
    need to be kept.
    - CAS (Deprecated)
    - String
    - Toggle
    - MarshallJSON
    - UnmarshallJSON
  • Update Pointer[T] to embed sync/atomic type.

I just wanted to document all this stuff before I forget.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the gen-atomicint entry point and review the existing Bool and Pointer[T] implementations alongside the generated atomic integer types. Compare their methods with the Go 1.19 sync/atomic types. Done means the duplicated methods are provided through embedded sync/atomic types while the listed additional methods remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.