So my application relies on a goroutine that polls every x seconds.
func main() {
// ...
go p.StartPoller();
}
What are some tips to make sure this poller is always running?
I'm just weary of things maybe because I don't understand fully the concept of error trapping in go. Since errors are values, and assuming I don't or any of the libraries I use call panic(), and no null pointer references or array out of bounds any code inside of this goroutine should not crash the goroutine correct?
func (p *Poller) StartPoller() {
ticker := time.NewTicker(3 * time.Second)
defer ticker.Stop()
for {
<-ticker.C
// code here
}
}