code: func (s *Discovery) Watch(stopCh <-chan struct{}) (<-chan discovery.Entries, <-chan error) {
  	ch := make(chan discovery.Entries)
  	errCh := make(chan error)
  	ticker := time.NewTicker(s.heartbeat)
  
  	go func() {
  		defer close(errCh)
  		defer close(ch)
  
  		// Send the initial entries if available.
  		currentEntries, err := s.fetch()
  		if err != nil {
  			errCh <- err
  		} else {
  			ch <- currentEntries
  		}
  
  		// Periodically send updates.
  		for {
  			select {
  			case <-ticker.C:
  				newEntries, err := s.fetch()
  				if err != nil {
  					errCh <- err
  					continue
  				}
  
  				// Check if the file has really changed.
  				if !newEntries.Equals(currentEntries) {
  					ch <- newEntries
  				}
  				currentEntries = newEntries
  			case <-stopCh:
  				ticker.Stop()
  				return
  			}
  		}
  	}()
  
  	return ch, errCh
  }
docs: // Watch is exported