func kickOffWatcher(c *imap.Client) { cmd, _ := c.Idle() for cmd.InProgress() { c.Data = nil c.Recv(-1) for _, rsp := range c.Data { if rsp.Label == "EXISTS" { newEmailCount := rsp.Fields[0].(uint32) if newEmailCount > curMsgCount { c.IdleTerm() notifyNewEmail(c, newEmailCount) kickOffWatcher(c) } curMsgCount = newEmailCount } } } }