Documentation ¶
Index ¶
- Variables
- func Exists(fname string) bool
- func Read(fname string, data interface{}) error
- func RemoveIfExists(fname string) error
- func Write(fname string, data interface{}, log slog.Logger) error
- type MatchedNumberedFile
- type NumberedFilePattern
- func (nfp NumberedFilePattern) FilenameFor(i uint64) string
- func (nfp NumberedFilePattern) Last(dir string) (MatchedNumberedFile, error)
- func (nfp NumberedFilePattern) MatchFiles(dir string) ([]MatchedNumberedFile, error)
- func (nfp NumberedFilePattern) NextFilename(dir string) (string, uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("json file not found")
Functions ¶
func RemoveIfExists ¶
RemoveIfExists removes the filename if it exists. If it does not exist, this doesn't return an error.
Types ¶
type MatchedNumberedFile ¶
MatchedNumberedFile is a matched numbered file.
type NumberedFilePattern ¶
type NumberedFilePattern struct {
// contains filtered or unexported fields
}
NumberedFilePattern can be used to match files in a dir.
func MakeDecimalFilePattern ¶
func MakeDecimalFilePattern(prefix, suffix string, isDir bool) NumberedFilePattern
MakeDecimalFilePattern creates a numbered file pattern that uses decimal encoded numbers. It panics if prefix+suffix cannot be made into a valid regexp.
func MakeHexFilePattern ¶
func MakeHexFilePattern(prefix, suffix string, isDir bool) NumberedFilePattern
MakeHexFilePattern creates a numbered file pattern that can handle hex encoded numbers. It panics if prefix+suffix cannot be made into a valid regexp.
func (NumberedFilePattern) FilenameFor ¶
func (nfp NumberedFilePattern) FilenameFor(i uint64) string
FilenameFor returns the filename for a given number.
func (NumberedFilePattern) Last ¶
func (nfp NumberedFilePattern) Last(dir string) (MatchedNumberedFile, error)
Last returns the number and filename of the file with highest number in the dir.
If no file is found, the returned filename is empty.
func (NumberedFilePattern) MatchFiles ¶
func (nfp NumberedFilePattern) MatchFiles(dir string) ([]MatchedNumberedFile, error)
MatchFiles returns the files that match the pattern in the given dir.
func (NumberedFilePattern) NextFilename ¶ added in v0.1.9
func (nfp NumberedFilePattern) NextFilename(dir string) (string, uint64, error)
NextFilename returns the next filename and ID for numbered files inside the given dir.