sum

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sum provides checksum storage and calculation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64

func Base64(in []byte) string

Base64 encodes in as a base64 string.

func Fnv128aPath

func Fnv128aPath(p string) (string, error)

Fnv128aPath returns the base64-encoded FNV-128a hash of the file at p.

func PathMatchesHash

func PathMatchesHash(p string, hasher HashPathFunc, expected string) (bool, error)

PathMatchesHash check if the file at the given path matches the given hash when hashed with hasher. If the target does not exist the functions returns (false, nil) as if the hash did not match.

func Sha512Path

func Sha512Path(p string) (string, error)

Sha512Path returns the base64-encoded SHA-512 hash of the file at p.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a key-value store for checksum entries.

func Open

func Open(p string) (*DB, error)

Open opens a DB at path p. If the path does not exist an empty DB will be returned.

func Read

func Read(in io.Reader) (*DB, error)

Read parses a DB from in.

func (*DB) Get

func (db *DB) Get(urlTemplate, inArchive, os, arch string) (Entry, bool)

Get retrieves an entry by key.

func (*DB) GetAll

func (db *DB) GetAll(urlTemplate, inArchive string) []Entry

GetAll retrieves all entries for the given URL template.

func (*DB) Save

func (db *DB) Save() error

Save writes the DB to its file path.

func (*DB) Set

func (db *DB) Set(urlTemplate, inArchive, os, arch, sum, comment string)

Set stores an entry.

func (*DB) Write

func (db *DB) Write(out io.Writer) error

Write writes the DB to the given writer.

type Entry

type Entry struct {
	URLTemplate string
	InArchive   string
	OS          string
	Arch        string
	Sum         string
	Comment     string
}

Entry represents a single checksum record.

func (Entry) Equal

func (e Entry) Equal(other Entry) bool

Equal returns true if the entry and other are identical.

type HashPathFunc

type HashPathFunc func(string) (string, error)

HashPathFunc is a function that hashes the file at the given path and returns the base64 encoded hash.

Jump to

Keyboard shortcuts

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