Skip to content

sync: get the size of sync.Map #20921

Closed
Closed
@AlexStocks

Description

@AlexStocks

What version of Go are you using (go version)?

go 1.9 beta2

What did you expect to see?

If use map, I can get the size of it by len(map). Whatever, how can I get the size of sync.Map?

What did you see instead?

Add function: func (m *Map) Len() int

Maybe Map should have a member "size int64". Map can change its value in Store & LoadOrStore & Delete by using atomic.AddInt64. And then (m Map) Len() can return m.size to get Map's size.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions