package
0.0.0-20240614095155-da5732d4417d
Repository: https://github.com/kjk/common.git
Documentation: pkg.go.dev
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Capitalize does foo => Foo, BAR => Bar etc.
CloseNoError is like io.Closer Close() but ignores an error use as: defer CloseNoError(f).
No description provided by the author
CopyFile copies a file from src to dst It'll create destination directory if necessary.
toZip is a list of files and directories in baseDir Directories are added recursively.
CreateZipWithDirContent creates a zip file with the content of a directory.
No description provided by the author
DirExists returns true if path exists and is a directory.
No description provided by the author
ExtEqualFold returns true if s ends with extension (e.g.
FileExists returns true if path exists and is a regular file.
FileLineCount returns number of lines in a file.
No description provided by the author
FileSize gets file size, -1 if file doesn't exist.
Formats duration in a more human friendly way than time.Duration.String().
FormatSize formats a number in a human-readable form e.g.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
call cb on each file in a directory.
call cb on each file in fsys startDir should be ".
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewLineStats returns new LineStats.
No description provided by the author
No description provided by the author
NormalizeNewlines is like NormalizeNewlinesInPlace but slower because it makes a copy of data.
NormalizeNewlinesInPlace changes CRLF (Windows) and CR (Mac) to LF (Unix) Optimized for speed, modifies data in place.
from https://gist.github.com/hyg/9c4afcd91fe24316cbf0.
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.
No description provided by the author
No description provided by the author
No description provided by the author
PathExists returns true if path exists.
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.
Percent returns how many percent of total is sub 100% means total == sub, 50% means sub = total / 2.
No description provided by the author
No description provided by the author
ReadFileMaybeCompressed reads file.
ReadLines reads file as lines.
ReadLinesFromReader reads lines from io.Reader.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Slug generates safe url from string by removing hazardous characters.
No description provided by the author
No description provided by the author
TrimExt removes extension from s.
TrimPrefix is like strings.TrimPrefix but also returns a bool indicating that the string was trimmed.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WriteFileGzipped writes data to a path, using best gzip compression.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
time.Duration with a better string representation.