Documentation
¶
Overview ¶
Package util implements general utility functionality for operations such as:
- file operations. - simple http operations. - a set collection implementation. - an unlimited channel (buffered channel) implementation.
Index ¶
- func CopyFile(src string, dest string) error
- func CopyToStream(src string, w io.Writer) (int64, error)
- func CreatePathForFile(path string) error
- func DigestFile(path string) (digest.Digest, error)
- func DirSize(fsys fs.FS) (int64, error)
- func GetDirLastUpdate(fsys fs.FS) (time.Time, error)
- func GetDirUpdatedPaths(fsys fs.FS, earliest time.Time) ([]string, error)
- func IsDirEmpty(path string) (bool, error)
- func UnlimitedChannel[T any](cancel context.Context) (in chan T, out chan T)
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyToStream ¶
CopyToStream opens the input file specified by src and copies it to the stream specified by w.
func CreatePathForFile ¶
CreatePathForFile creates a directory if one does not exist that can contain the provided file path. no file is created, only the directory path is created.
func DigestFile ¶
DigestFile calculates a SHA256 hash for a given file path. TODO pass an argument to be able to change the digest algorithm.
func GetDirLastUpdate ¶
GetDirLastUpdate returns the last update time of a directory.
func GetDirUpdatedPaths ¶
GetDirUpdatedPaths returns a list of paths that have been updated since the given time.
func IsDirEmpty ¶
IsDirEmpty returns true, nil if a directory is empty from https://stackoverflow.com/questions/30697324/how-to-check-if-directory-on-path-is-empty
func UnlimitedChannel ¶
UnlimitedChannel creates an input/output channel pair that provides the behavior of an unlimited buffered channel. the internal go routine blocks on waiting for items to appear on the input channel, and adds them to a list of items when one is received.
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set provides a set-like container for strings implemented using a map.
func NewSetFromList ¶
NewSetFromList creates a set from a given slice of strings.