Documentation
¶
Overview ¶
Package hashfile computes a deterministic content+filename hash over a set of file paths, the shared hashing primitive behind pkg/runner/freshness's checksum.changed fact.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashFiles ¶
HashFiles computes a deterministic hash over paths: sorted first (so input order never affects the result), then path+content streamed into one sha256 digest (the path, not just its base name, is included so both a rename and a move between directories that share a filename are detected even when content is unchanged). Each record is length-prefixed (see writeRecord) so no concatenation of two records can ever collide with a different pair of path/content values. Returns the full hex-encoded digest; callers wanting a short prefix (e.g. cache keys) can slice it.
func HashFilesAndRecords ¶
HashFilesAndRecords extends HashFiles with an additional set of opaque string records (e.g. "key=value" facts that should invalidate the digest when they change but have no file backing them); records are sorted before hashing, so callers never need to pre-sort them and the result is stable regardless of the order records are supplied in. Passing a nil or empty records slice produces a digest byte-identical to HashFiles(paths).
func HashNamedFiles ¶
HashNamedFiles computes a deterministic hash over a set of files keyed by a caller-supplied name rather than their filesystem path, so the resulting digest is independent of where the files physically live (e.g. two checkouts of the same component at different absolute paths produce identical digests); named maps each logical name to the path whose content should be read for it; names are sorted before hashing so map iteration order never affects the result. The records parameter behaves exactly as in HashFilesAndRecords.
Types ¶
This section is empty.