hash

package
v0.0.0-...-34138cd Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

Hash

Provides simple and efficient helpers to hash files or directories for content addressability needs.

Documentation

Overview

Package hash provides file and directory hashing utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileOpen indicates failure to open file for hashing.
	ErrFileOpen = errors.New("failed to open file")

	// ErrFileRead indicates failure to read file content.
	ErrFileRead = errors.New("failed to read file content")

	// ErrFileStat indicates failure to stat file or directory.
	ErrFileStat = errors.New("failed to stat path")

	// ErrPathRelative indicates failure to compute relative path.
	ErrPathRelative = errors.New("failed to compute relative path")

	// ErrDirectoryWalk indicates failure while walking directory tree.
	ErrDirectoryWalk = errors.New("failed to walk directory tree")
)

Functions

func Directory

func Directory(dirPath string) (string, error)

Directory recursively hashes a directory tree.

func File

func File(path string) (string, error)

File computes the SHA256 hash of a file.

func Path

func Path(path string) (string, error)

Path computes the SHA256 hash of a file or directory. For files: hash the content. For directories: hash the entire tree (paths + contents).

Types

This section is empty.

Jump to

Keyboard shortcuts

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