fileutil

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 ReadFileWithSHA256HexDigest

func ReadFileWithSHA256HexDigest(path string) ([]byte, string, error)

ReadFileWithSHA256HexDigest reads the full contents of the file at path and returns both the raw bytes and their hex-encoded SHA-256 digest. Use this instead of SHA256HexDigest when the caller also needs the file contents (e.g. to upload them), so the file is only read once.

func SHA256HexDigest

func SHA256HexDigest(path string) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL