Skip to content

proposal: typesafe sync.Map - affected/package: /x/sync #52085

Closed
@kf6nux

Description

@kf6nux

Background

sync.Map was useful enough to be promoted from /x/, but was made before generics and utilizes interface{} (now any)

Proposal

Re-implement the existing API of sync.Map using generics for added type safety/convenience. Use alternate struct name to maintain backward compatibility (e.g. sync.MapGeneric)

Release

Release to /x/sync first while feedback is submitted.

Additional considerations

Proposal #47643 requested support for additional algorithms for additional use cases. We may want to allow the sync.Map's implementation algorithm to be user selectable. If so, I'd propose adding a method that can optionally be invoked on newly created sync.MapGeneric structs to specify the backing algorithm.

Separately

I volunteer to do the work.

Activity

added this to the Proposal milestone on Mar 31, 2022
kf6nux

kf6nux commented on Mar 31, 2022

@kf6nux
Author

Ah, I was just informed this is also being discussed here #48287

ianlancetaylor

ianlancetaylor commented on Mar 31, 2022

@ianlancetaylor
Contributor

Thanks. See also #47657. Closing as dup.

locked and limited conversation to collaborators on Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ianlancetaylor@gopherbot@kf6nux

        Issue actions

          proposal: typesafe sync.Map - affected/package: /x/sync · Issue #52085 · golang/go