Documentation
¶
Overview ¶
Package fileutil provides shared helpers for computing and comparing file checksums, used by resources that detect drift in a file referenced by path (e.g. package archives, investigation guide content).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileChecksumDrifted ¶
func FileChecksumDrifted(path string, priorChecksum string, hasPriorState bool) (newChecksum string, changed bool, err error)
FileChecksumDrifted computes the current SHA-256 digest of the file at path and reports whether it differs from priorChecksum. hasPriorState must be false when the resource is being created (there is no prior state to compare against); in that case changed is true when the digest is computed successfully. Otherwise, changed reports whether newChecksum != priorChecksum.
func SHA256HexDigest ¶
SHA256HexDigest returns the hex-encoded SHA-256 digest of the file at path. It streams the file contents rather than loading the whole file into memory, so it is safe to use on large files.
Types ¶
This section is empty.