code: func (op *PortAllocationOperation) AllocateNext() (int, error) {
  	if op.dryRun {
  		// Find the max element of the allocated ports array.
  		// If no ports are already being allocated by this operation,
  		// then choose a sensible guess for a dummy port number
  		var lastPort int
  		for _, allocatedPort := range op.allocated {
  			if allocatedPort > lastPort {
  				lastPort = allocatedPort
  			}
  		}
  		if len(op.allocated) == 0 {
  			lastPort = 32768
  		}
  
  		// Try to find the next non allocated port.
  		// If too many ports are full, just reuse one,
  		// since this is just a dummy value.
  		for port := lastPort + 1; port < 100; port++ {
  			err := op.Allocate(port)
  			if err == nil {
  				return port, nil
  			}
  		}
  		op.allocated = append(op.allocated, lastPort+1)
  		return lastPort + 1, nil
  	}
  
  	port, err := op.pa.AllocateNext()
  	if err == nil {
  		op.allocated = append(op.allocated, port)
  	}
  	return port, err
  }
docs: // Allocates a port, and record it for future rollback