I have a map with objects that needs to be released before clearing the map. I am tempted to iterate over the map and remove/release objects as I walk through it.
Here is a mock up example https://play.golang.org/p/kAtPoUgMsq
Since the only way to iterate the map is through range, how would I synchronize multiple producers and multiple consumers?
I don't want to read lock the map since that would make delete/modifying keys during the iteration impossible.