code: func PatchDelta(src, delta []byte) ([]byte, error) {
  	if len(delta) < deltaSizeMin {
  		return nil, ErrInvalidDelta
  	}
  
  	srcSz, delta := decodeLEB128(delta)
  	if srcSz != uint(len(src)) {
  		return nil, ErrInvalidDelta
  	}
  
  	targetSz, delta := decodeLEB128(delta)
  	remainingTargetSz := targetSz
  
  	var cmd byte
  	dest := make([]byte, 0, targetSz)
  	for {
  		if len(delta) == 0 {
  			return nil, ErrInvalidDelta
  		}
  
  		cmd = delta[0]
  		delta = delta[1:]
  		if isCopyFromSrc(cmd) {
  			var offset, sz uint
  			var err error
  			offset, delta, err = decodeOffset(cmd, delta)
  			if err != nil {
  				return nil, err
  			}
  
  			sz, delta, err = decodeSize(cmd, delta)
  			if err != nil {
  				return nil, err
  			}
  
  			if invalidSize(sz, targetSz) ||
  				invalidOffsetSize(offset, sz, srcSz) {
  				break
  			}
  			dest = append(dest, src[offset:offset+sz]...)
  			remainingTargetSz -= sz
  		} else if isCopyFromDelta(cmd) {
  			sz := uint(cmd) // cmd is the size itself
  			if invalidSize(sz, targetSz) {
  				return nil, ErrInvalidDelta
  			}
  
  			if uint(len(delta)) < sz {
  				return nil, ErrInvalidDelta
  			}
  
  			dest = append(dest, delta[0:sz]...)
  			remainingTargetSz -= sz
  			delta = delta[sz:]
  		} else {
  			return nil, ErrDeltaCmd
  		}
  
  		if remainingTargetSz <= 0 {
  			break
  		}
  	}
  
  	return dest, nil
  }
docs: // PatchDelta returns the result of applying the modification deltas in delta to src.
  // An error will be returned if delta is corrupted (ErrDeltaLen) or an action command
  // is not copy from source or copy from delta (ErrDeltaCmd).