Documentation
¶
Index ¶
- func BrCompressData(d []byte, level int) ([]byte, error)
- func BrCompressDataBest(d []byte) ([]byte, error)
- func BrCompressDataDefault(d []byte) ([]byte, error)
- func BrCompressFile(dstPath string, path string, level int) error
- func BrCompressFileBest(dstPath string, path string) error
- func BrCompressFileDefault(dstPath string, path string) error
- func BrDecompressData(d []byte) ([]byte, error)
- func BrReadFile(path string) ([]byte, error)
- func CloseNoError(f io.Closer)
- func CopyFile(dst string, src string) error
- func CountFilesInFS(fsys fs.ReadDirFS) int
- func CreateZipFile(dst string, baseDir string, toZip ...string)
- func CreateZipWithDirContent(zipFilePath, dirToZip string) error
- func DataSha1Hex(d []byte) string
- func DirExists(path string) bool
- func DirFSIter(fsys fs.ReadDirFS, startDir string) iter.Seq[*DirEntryWithPath]
- func ExpandTildeInPath(s string) string
- func ExtEqualFold(s string, ext string) bool
- func FileExists(path string) bool
- func FileSha1Hex(path string) (string, error)
- func FileSize(path string) int64
- func GetCallstack(skipFrames int) string
- func GetCallstackFrames(skipFrames int) []string
- func GetErr(errs ...error) error
- func GzipCompressData(d []byte) ([]byte, error)
- func GzipCompressFile(dstPath, srcPath string) error
- func GzipDecompressData(d []byte) ([]byte, error)
- func GzipReadFile(path string) ([]byte, error)
- func InlineFlateCompress(plain []byte) []byte
- func IsLinux() bool
- func IsMac() bool
- func IsWinOrMac() bool
- func IsWindows() bool
- func IterDir(dir string, cb func(path string, de fs.DirEntry) (bool, error)) error
- func IterReadDirFS(fsys fs.ReadDirFS, startDir string, cb func(string, fs.DirEntry) error) error
- func IterZipData(zipData []byte, cb func(f *zip.File, data []byte) error) error
- func IterZipReader(r *zip.Reader, cb func(f *zip.File, data []byte) error) error
- func MaybeSync(w io.Writer) error
- func Must(err error)
- func Must2[T any](x T, err error) T
- func OpenFileMaybeCompressed(path string) (io.ReadCloser, error)
- func PanicIf(cond bool, args ...any)
- func PanicIfErr(err error, args ...any)
- func PathExists(path string) bool
- func PathIsDir(path string) (isDir bool, err error)
- func Push[S ~[]E, E any](s *S, els ...E)
- func ReadBeInt16(r io.Reader) (val int16)
- func ReadBeInt32(r io.Reader) (val int32)
- func ReadBeInt64(r io.Reader) (val int64)
- func ReadByte(r io.Reader) (val byte)
- func ReadFileMaybeCompressed(path string) ([]byte, error)
- func ReadLeInt16(r io.Reader) (val int16)
- func ReadLeInt32(r io.Reader) (val int32)
- func ReadLeInt64(r io.Reader) (val int64)
- func ReadLines(filePath string) ([]string, error)
- func ReadLinesFromReader(r io.Reader) ([]string, error)
- func ReadZipData(zipData []byte) (map[string][]byte, error)
- func ReadZipFile(path string) (map[string][]byte, error)
- func ReadZipFileMust(path string) map[string][]byte
- func RunLoggedInDir(dir string, exe string, args ...string) error
- func RunLoggedInDirMust(dir string, exe string, args ...string)
- func RunLoggedMust(exe string, args ...string) string
- func RunMust(exe string, args ...string) string
- func SliceLimit[S ~[]E, E any](s S, max int) S
- func TrimExt(s string) string
- func UnzipDataToDir(zipData []byte, dir string) error
- func WriteFileGzipped(path string, data []byte) error
- func WriteToFile(path string, content string) error
- func ZipDir(dirToZip string) ([]byte, error)
- func ZipDirToWriter(w io.Writer, dirToZip string) error
- func ZstdCompressData(d []byte, level zstd.EncoderLevel) ([]byte, error)
- func ZstdCompressDataBest(d []byte) ([]byte, error)
- func ZstdCompressDataDefault(d []byte) ([]byte, error)
- func ZstdCompressFile(dst string, src string, level zstd.EncoderLevel) error
- func ZstdCompressFileBest(dst string, src string) error
- func ZstdCompressFileDefault(dst string, src string) error
- func ZstdDecompressData(d []byte) ([]byte, error)
- func ZstdReadFile(path string) ([]byte, error)
- type DirEntryWithPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrCompressDataBest ¶
func BrCompressDataDefault ¶
func BrCompressFileBest ¶
func BrCompressFileDefault ¶
func BrDecompressData ¶
func BrReadFile ¶
func CloseNoError ¶
CloseNoError is like io.Closer Close() but ignores an error use as: defer CloseNoError(f)
func CopyFile ¶
CopyFile copies a file from src to dst It'll create destination directory if necessary
func CountFilesInFS ¶
func CreateZipFile ¶
toZip is a list of files and directories in baseDir Directories are added recursively
func CreateZipWithDirContent ¶
CreateZipWithDirContent creates a zip file with the content of a directory. The names of files inside the zip file are relatitve to dirToZip e.g. if dirToZip is foo and there is a file foo/bar.txt, the name in the zip will be bar.txt
func DataSha1Hex ¶
func DirFSIter ¶
DirFSIter iterates over all entries and sub-entries in fsys starting from startDir. For each entry, it yields path relative to the root of fsys. Only provides files, not dirs.
func ExpandTildeInPath ¶
func ExtEqualFold ¶
ExtEqualFold returns true if s ends with extension (e.g. ".html") case-insensitive
func FileExists ¶
FileExists returns true if path exists and is a regular file
func FileSha1Hex ¶
func GetCallstack ¶
func GetCallstackFrames ¶
func GzipCompressData ¶
func GzipCompressFile ¶
func GzipDecompressData ¶
func GzipReadFile ¶
func InlineFlateCompress ¶
func IsWinOrMac ¶
func IsWinOrMac() bool
func IterReadDirFS ¶
call cb on each file in fsys startDir should be ". for root directory, "" and "/" do not work
func IterZipReader ¶
func OpenFileMaybeCompressed ¶
func OpenFileMaybeCompressed(path string) (io.ReadCloser, error)
OpenFileMaybeCompressed opens a file that might be compressed with gzip or bzip2 or zstd or brotli TODO: could sniff file content instead of checking file extension
func PanicIfErr ¶
func PathIsDir ¶
PathIsDir returns true if a path exists and is a directory Returns false, nil if a path exists and is not a directory (e.g. a file) Returns undefined, error if there was an error e.g. because a path doesn't exists
func ReadBeInt16 ¶
func ReadBeInt32 ¶
func ReadBeInt64 ¶
func ReadFileMaybeCompressed ¶
ReadFileMaybeCompressed reads file. Ungzips if it's gzipped.
func ReadLeInt16 ¶
func ReadLeInt32 ¶
func ReadLeInt64 ¶
func ReadLinesFromReader ¶
ReadLinesFromReader reads lines from io.Reader
func ReadZipFileMust ¶
func RunLoggedInDirMust ¶
func RunLoggedMust ¶
func SliceLimit ¶
func UnzipDataToDir ¶
func WriteFileGzipped ¶
WriteFileGzipped writes data to a path, using best gzip compression
func WriteToFile ¶
func ZstdCompressData ¶
func ZstdCompressData(d []byte, level zstd.EncoderLevel) ([]byte, error)
func ZstdCompressDataBest ¶
func ZstdCompressDataDefault ¶
func ZstdCompressFile ¶
func ZstdCompressFile(dst string, src string, level zstd.EncoderLevel) error