Documentation
¶
Overview ¶
Package par2go implements a pure Go PAR2 parity file creator.
It creates PAR2 recovery files compatible with par2cmdline, MultiPar, and other PAR2-compliant tools, without requiring any external binaries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create creates PAR2 parity files for the given input files.
outputPath is the path for the main .par2 file (e.g., "/path/to/file.par2"). Volume files will be created alongside with names like file.vol00+01.par2.
FileDesc filenames are set to filepath.Base of each input path. Use CreateWithNames to embed relative paths instead.
func CreateWithNames ¶ added in v0.0.8
func CreateWithNames(ctx context.Context, outputPath string, inputs []InputFile, opts Options) error
CreateWithNames is like Create but allows callers to specify the logical filename (including a relative path) for each input file. All inputs are bundled into a single par2 set written to outputPath.
Types ¶
type InputFile ¶ added in v0.0.8
InputFile pairs an on-disk path with the logical filename to embed in the PAR2 FileDesc packet.
Name should use forward-slash separators for relative paths (e.g. "folder2/file.txt"). When Name is empty, filepath.Base(Path) is used, matching the behavior of Create.
Embedding relative paths makes downloaders such as SABnzbd and NZBGet reconstruct the original folder tree on disk after par2 verification (they use the FileDesc filename to rename downloaded flat files into subdirectories). This matches the default behavior of ParPar.
Name is rejected if it contains a backslash, is absolute, or contains a ".." segment, to prevent path-traversal in downstream consumers.
type Options ¶
type Options struct {
// SliceSize is the block/slice size in bytes. Must be a multiple of 4.
SliceSize int
// NumRecovery is the number of recovery blocks to create.
NumRecovery int
// NumGoroutines is the number of parallel GF compute threads (default: runtime.NumCPU()).
// Pass 0 to use hardware_concurrency() auto-detection.
NumGoroutines int
// MemoryLimit caps the memory used for recovery output buffers (in bytes).
// When NumRecovery * SliceSize exceeds this limit, encoding is split into
// multiple passes over the input files, each processing a subset of recovery
// blocks that fits within the budget. This dramatically improves cache locality
// for large recovery counts at the cost of re-reading input files.
// Default 0 means automatic (min of 75% physical RAM or 4 GiB).
MemoryLimit int64
// Method forces a specific GF16 SIMD method (0 = auto-detect).
// Use parpar.GF16Auto, parpar.GF16ShuffleAVX2, parpar.GF16ClmulNEON, etc.
Method int
// InputGrouping controls the input batch size for the GF16 encoder.
// 0 means auto-detect (typically ~12). Higher values use more memory
// but may improve throughput.
InputGrouping int
// ChunkLen controls the sub-slice chunk length for parallel GF16 processing.
// 0 means auto-detect based on the SIMD method's ideal chunk size.
ChunkLen int
// StagingAreas controls the number of double-buffered staging areas in the
// GF16 encoder. Default 0 means 2. More areas can overlap I/O and compute.
StagingAreas int
// OnProgress reports progress: phase is "hashing", "encoding", or "writing", pct is 0.0-1.0.
OnProgress func(phase string, pct float64)
// Creator is the creator string embedded in the PAR2 file (default: "Postie").
Creator string
// Logger is the structured logger used internally. Defaults to discarding all output.
// Set to slog.Default() or a custom *slog.Logger to enable logging.
Logger *slog.Logger
}
Options configures PAR2 creation.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
benchmark
command
Command benchmark compares par2go throughput against the parpar binary.
|
Command benchmark compares par2go throughput against the parpar binary. |
|
internal
|
|
|
packets
Package packets implements the PAR2 binary packet format per the PAR2 specification.
|
Package packets implements the PAR2 binary packet format per the PAR2 specification. |
|
parpar
Package parpar provides Go bindings to ParPar's PAR2ProcCPU controller, which implements threaded PAR2-compatible Reed-Solomon encoding with optimized SIMD backends for 33+ CPU variants (SSE2, SSSE3, AVX, AVX2, AVX-512, GFNI, NEON, SVE, CLMul, RISC-V, etc.) and runtime CPU detection.
|
Package parpar provides Go bindings to ParPar's PAR2ProcCPU controller, which implements threaded PAR2-compatible Reed-Solomon encoding with optimized SIMD backends for 33+ CPU variants (SSE2, SSSE3, AVX, AVX2, AVX-512, GFNI, NEON, SVE, CLMul, RISC-V, etc.) and runtime CPU detection. |