Documentation ¶
Overview ¶
Package util contains utility types and functions
Index ¶
- func CheckDir(p string) error
- func CheckFile(p string) error
- func FilterSongs(files []string) []string
- func IsCanceled(ctx context.Context) bool
- func IsDir(p string) bool
- func IsFile(p string) bool
- func ListAllFiles(songsDir string, subDir string) []string
- func ListAllSubDirs(dir string) []string
- func ListGlobFiles(dir, pattern string) ([]string, error)
- type ErrorCollector
- type MultiError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDir ¶
CheckDir checks whether a directory exists and is in fact a directory (returns an error if that is not the case)
func CheckFile ¶
CheckFile checks whether a file exists and is in fact a file (returns an error if that is not the case)
func FilterSongs ¶
FilterSongs removes all non-songs from the files slice
func IsCanceled ¶
IsCanceled returned whether the context is canceled
func ListAllFiles ¶
ListAllFiles recursively lists all files in songsDir/subDir
func ListAllSubDirs ¶
ListAllSubDirs recursively lists all directories in dir
func ListGlobFiles ¶
ListGlobFiles lists all files in a directory matching the provided glob pattern
Types ¶
type ErrorCollector ¶
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector is a thread save utility class to collect multiple errors into one slice
func (*ErrorCollector) Add ¶
func (ec *ErrorCollector) Add(err error)
Add adds an error to the ErrorCollector
func (*ErrorCollector) Err ¶
func (ec *ErrorCollector) Err(baseMessage string) error
Err returns an MultiError containing all errors added using Add, with baseMessage as base message If no errors were added, it returns nil
func (*ErrorCollector) Wait ¶
func (ec *ErrorCollector) Wait()
Wait waits for all pending error insertions to complete
type MultiError ¶
MultiError is an error containing multiple errors
func NewMultiError ¶
func NewMultiError(baseMessage string, errors []error) MultiError
NewMultiError creates a MultiError from a base message and a slice of errors