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.
This change wouldn't break existing code.
Yes, it would:
var deleteFn func(interface{}) = m.Delete
Yeah, we can't change any API signatures. See also: https://blog.merovius.de/2015/07/29/backwards-compatibility-in-go.html
We can't change this signature.
Most helpful comment
Yes, it would: