"is it safe to be removed from map in a concurrent environment? in golang" Code Answer

5

deleting from a map is considered a write operation, and must be serialized with all other reads and writes. if i understand your question correctly, then yes you need to either batch the deletes for later, or give up the read lock and take a write lock to complete the delete.

the runtime attempts to detect concurrent reads and writes, and will crash with one of:

fatal error: concurrent map writes
fatal error: concurrent map read and map write
By akash87 on August 26 2022

Answers related to “is it safe to be removed from map in a concurrent environment? in golang”

Only authorized users can answer the Search term. Please sign in first, or register a free account.