code: func (l *State) deleteCheck(id types.CheckID) error {
  	if id == "" {
  		return fmt.Errorf("CheckID missing")
  	}
  
  	req := structs.DeregisterRequest{
  		Datacenter:   l.config.Datacenter,
  		Node:         l.config.NodeName,
  		CheckID:      id,
  		WriteRequest: structs.WriteRequest{Token: l.checkToken(id)},
  	}
  	var out struct{}
  	err := l.Delegate.RPC("Catalog.Deregister", &req, &out)
  	switch {
  	case err == nil || strings.Contains(err.Error(), "Unknown check"):
  		c := l.checks[id]
  		if c != nil && c.DeferCheck != nil {
  			c.DeferCheck.Stop()
  		}
  		delete(l.checks, id)
  		l.logger.Printf("[INFO] agent: Deregistered check %q", id)
  		return nil
  
  	case acl.IsErrPermissionDenied(err), acl.IsErrNotFound(err):
  		// todo(fs): mark the check to be in sync to prevent excessive retrying before next full sync
  		// todo(fs): some backoff strategy might be a better solution
  		l.checks[id].InSync = true
  		l.logger.Printf("[WARN] agent: Check %q deregistration blocked by ACLs", id)
  		metrics.IncrCounter([]string{"acl", "blocked", "check", "deregistration"}, 1)
  		return nil
  
  	default:
  		l.logger.Printf("[WARN] agent: Deregistering check %q failed. %s", id, err)
  		return err
  	}
  }
docs: // deleteCheck is used to delete a check from the server