helper

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidHash is returned if the hash is invalid.
	ErrInvalidHash = errors.New("invalid hash")

	// ErrInputTooShort is returned if the input is too short.
	ErrInputTooShort = errors.New("input is less than 3 characters long")
)
View Source
var ErrInvalidSizeSuffix = errors.New("invalid size suffix")

ErrInvalidSizeSuffix is returned if the suffix is not valid.

Functions

func FilePathWithSharding added in v0.0.12

func FilePathWithSharding(fn string) (string, error)

FilePathWithSharding returns the path to a file with sharding.

func IsValidHash added in v0.8.2

func IsValidHash(hash string) bool

IsValidHash returns true if the hash is valid (32 or 52 lowercase alphanumeric characters).

func MustRandString added in v0.0.11

func MustRandString(n int, r io.Reader) string

MustRandString returns the string returned by RandString. If RandString returns an error, it will panic.

func NarFilePath added in v0.0.12

func NarFilePath(hash, compression string) (string, error)

NarFilePath returns the path of the nar file given a hash and an optional compression.

func NarInfoFilePath added in v0.0.12

func NarInfoFilePath(hash string) (string, error)

NarInfoFilePath returns the path of the narinfo file given a hash.

func NarInfoURLPath added in v0.0.12

func NarInfoURLPath(hash string) string

NarInfoURLPath returns the path of the narinfo file given a hash.

func ParseSize added in v0.0.11

func ParseSize(str string) (uint64, error)

ParseSize parses size with units and returns the same size in bytes.

func RandString added in v0.0.4

func RandString(n int, r io.Reader) (string, error)

RandString returns a random string of length n using r as the random reader; If r is nil, rand.Reader will be used instead.

func ValidateHash added in v0.8.2

func ValidateHash(hash string) error

ValidateHash validates the given hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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