code: func (s semaphore) wait(ctx context.Context) error {
  	// Always check Err first. "select" randomly selects a channel when both
  	// channels are available, and we want to prioritize cancelation.
  	if err := ctx.Err(); err != nil {
  		return err
  	}
  	select {
  	case <-ctx.Done():
  		// Err() is guaranteed to be non-nil.
  		return ctx.Err()
  	case <-s:
  		/*
  			// Do a last check, just in case. It makes things slightly slower but
  			// reduces the chance of race condition with having a spurious item running
  			// after cancelation.
  			if err := ctx.Err(); err != nil {
  				s.signal()
  				return err
  			}
  		*/
  		return nil
  	}
  }
docs: // wait waits for the Semaphore to have 1 item available.
  //
  // If nil is returned, the caller must call .signal() afterward.