I have a timer which is reset by certain events. A go function listens to the channel using range. How do I close the channel so that for loop exits?
func resetTimer(){
if rf.electionTimer != nil {
rf.electionTimer.Stop()
}
}
rf.electionTimer = time.NewTimer(electionTime)
for _ = range rf.electionTimer.C {
// Do something
}