Documentation
¶
Overview ¶
Package Hashing computes BLAKE3 content hashes of files and directory trees. File hash = "F"+base32(digest); dir hash = "D"+base32 of a name-sorted "<hash>\t<name>\n" manifest.
Index ¶
- Constants
- Variables
- func CombineHashes[T HashEntry[T]](items []T) string
- func CombineHashesInPlace[T HashEntry[T]](items []T) string
- func Hash(fsys vfs.Fs, path string) string
- func HashBytes(data []byte) string
- func HashDir(fsys vfs.Fs, dir string) string
- func HashDirFiltered(fsys vfs.Fs, dir string, dirSkipFn func(vfs.Fs, string, fs.FileInfo) bool) string
- func HashFile(fsys vfs.Fs, file string) string
- func HashLink(fsys vfs.Fs, path string) string
- func HashPath(path string) string
- func HashUrl(url string) string
- func IsValidBuildHash(s string) bool
- func IsValidDirHash(s string) bool
- func IsValidFileHash(s string) bool
- func IsValidPathHash(s string) bool
- func IsValidUrlHash(s string) bool
- type FileHasher
- type HashEntry
- type NamedEntry
Constants ¶
View Source
const ( FilePrefix = "F" DirPrefix = "D" BuildPrefix = "B" // prepended by Build to CombineHashes output, which emits no prefix UrlPrefix = "U" PathPrefix = "P" )
View Source
const EmptyDirHash = DirPrefix + "v4jutopv7gq2nicajxvdnxgjjgn4wjojvxarfn6mtkj4vza7gjra"
A constant rather than init-computed; TestEmptyDirHash pins it to the algorithm.
Variables ¶
View Source
var SafeHashing bool
Not synchronized — set once at startup, before hashing starts.
Functions ¶
func CombineHashes ¶
func CombineHashesInPlace ¶
It SORTS items slice in place (no copy)
func Hash ¶
This one-path entry must discover a root link itself, so `bufa hash <dangling-link>` names the link and its target instead of failing as an opaque Stat error.
func HashDirFiltered ¶
func IsValidBuildHash ¶
func IsValidDirHash ¶
func IsValidFileHash ¶
func IsValidPathHash ¶
func IsValidUrlHash ¶
Types ¶
type FileHasher ¶
type FileHasher struct {
// contains filtered or unexported fields
}
func NewFileHasher ¶
func NewFileHasher() *FileHasher
func (*FileHasher) Sum ¶
func (f *FileHasher) Sum() string
type NamedEntry ¶
type NamedEntry struct{ Name, Hash string }
func (NamedEntry) Compare ¶
func (e NamedEntry) Compare(o NamedEntry) int
func (NamedEntry) String ¶
func (e NamedEntry) String() string
Click to show internal directories.
Click to hide internal directories.