code: func (d *deadlineTimer) setDeadline(cancelCh *chan struct{}, timer **time.Timer, t time.Time) {
  	if *timer != nil && !(*timer).Stop() {
  		*cancelCh = make(chan struct{})
  	}
  
  	// Create a new channel if we already closed it due to setting an already
  	// expired time. We won't race with the timer because we already handled
  	// that above.
  	select {
  	case <-*cancelCh:
  		*cancelCh = make(chan struct{})
  	default:
  	}
  
  	// "A zero value for t means I/O operations will not time out."
  	// - net.Conn.SetDeadline
  	if t.IsZero() {
  		return
  	}
  
  	timeout := t.Sub(time.Now())
  	if timeout <= 0 {
  		close(*cancelCh)
  		return
  	}
  
  	// Timer.Stop returns whether or not the AfterFunc has started, but
  	// does not indicate whether or not it has completed. Make a copy of
  	// the cancel channel to prevent this code from racing with the next
  	// call of setDeadline replacing *cancelCh.
  	ch := *cancelCh
  	*timer = time.AfterFunc(timeout, func() {
  		close(ch)
  	})
  }
docs: // setDeadline contains the shared logic for setting a deadline.
  //
  // cancelCh and timer must be pointers to deadlineTimer.readCancelCh and
  // deadlineTimer.readTimer or deadlineTimer.writeCancelCh and
  // deadlineTimer.writeTimer.
  //
  // setDeadline must only be called while holding d.mu.