You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose that you expose a bool return variable in the sync map, changing it from:
func (m *Map) Delete(key interface{})
to:
func (m *Map) Delete(key interface{}) bool
The return value tells the caller whether the item was removed from the Map or not (true if key was in the map, false if the call did not change anything). It seems Map.Delete calls Map.delete internally, which already has the return data needed in some cases.
This change wouldn't break existing code.
The text was updated successfully, but these errors were encountered:
bradfitz
changed the title
sync.Map: Delete method should return bool, indicating if key was deleted or not
proposal: sync: Map.Delete method should return bool, indicating if key was deleted or not
Jan 25, 2018
I propose that you expose a bool return variable in the sync map, changing it from:
func (m *Map) Delete(key interface{})
to:
func (m *Map) Delete(key interface{}) bool
The return value tells the caller whether the item was removed from the Map or not (true if key was in the map, false if the call did not change anything). It seems Map.Delete calls Map.delete internally, which already has the return data needed in some cases.
This change wouldn't break existing code.
The text was updated successfully, but these errors were encountered: