code: func (a *Agent) cleanupRegistration(serviceIDs []string, checksIDs []types.CheckID) {
  	for _, s := range serviceIDs {
  		if err := a.State.RemoveService(s); err != nil {
  			a.logger.Printf("[ERR] consul: service registration: cleanup: failed to remove service %s: %s", s, err)
  		}
  		if err := a.purgeService(s); err != nil {
  			a.logger.Printf("[ERR] consul: service registration: cleanup: failed to purge service %s file: %s", s, err)
  		}
  	}
  
  	for _, c := range checksIDs {
  		a.cancelCheckMonitors(c)
  		if err := a.State.RemoveCheck(c); err != nil {
  			a.logger.Printf("[ERR] consul: service registration: cleanup: failed to remove check %s: %s", c, err)
  		}
  		if err := a.purgeCheck(c); err != nil {
  			a.logger.Printf("[ERR] consul: service registration: cleanup: failed to purge check %s file: %s", c, err)
  		}
  	}
  }
docs: // cleanupRegistration is called on  registration error to ensure no there are no
  // leftovers after a partial failure