I have a map:
var sessions = map[string] chan int{}
How do I delete sessions[key]? I tried:
sessions[key]
sessions[key] = nil,
From Effective Go:
To delete a map entry, use the delete built-in function, whose arguments are the map and the key to be deleted. It's safe to do this even if the key is already absent from the map. delete(timeZone, "PDT") // Now on Standard Time
To delete a map entry, use the delete built-in function, whose arguments are the map and the key to be deleted. It's safe to do this even if the key is already absent from the map.
delete(timeZone, "PDT") // Now on Standard Time