Documentation
¶
Index ¶
- func CountFiles(dir string, subfix string, skipdir string) (int, int)
- func CountLines(text string) []int
- func CountLinesCached(key string, text string) *[]int
- func CountLinesPooled(text string) *[]int
- func DedupSlice[T comparable](s []T) []T
- func FirstFile(dir string, subfix string, skipdir string) string
- func MustWriteFile(fpath string, data []byte) error
- func PutCount(count *[]int)
- func WrapError(err error, msg string, v ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountFiles ¶
count files and total size with specific subfix in a directory recursively
func CountLines ¶
CountLines calculates the starting offsets of lines in a given text. Each offset marks the byte position of the character immediately following a newline character, or 0 for the very beginning of the text.
func CountLinesCached ¶
The cached version of CountLines. Avoids redundant computations for the same text. Use when the same text is processed multiple times, such as contents of a file.
The key MUST uniquely identify the text i.e. for any two invocations
CountLinesCached(key1, text1) and CountLinesCached(key2, text2),
if key1 == key2, then text1 must be equal to text2 (and also vice versa).
func CountLinesPooled ¶
The pooled version of CountLines. Eases burden on allocation and GC. Use when invocation on small text is frequent.
MUST manually invoke `PutCount` when done with the result to return the slice to the pool.
func DedupSlice ¶
func DedupSlice[T comparable](s []T) []T
func MustWriteFile ¶
Types ¶
This section is empty.