Documentation ¶
Index ¶
- func MD5Sum(r io.Reader) (string, error)
- func MD5SumFile(path string) (string, error)
- func MD5SumStr(content string) (string, error)
- func PathExists(path string) (bool, error)
- func RemoveEmptyElements[T any](arr []T) []T
- func SHA1Sum(r io.Reader) (string, error)
- func SHA1SumFile(path string) (string, error)
- func SHA1SumStr(content string) (string, error)
- func SHA256Sum(r io.Reader) (string, error)
- func SHA256SumFile(path string) (string, error)
- func SHA256SumStr(content string) (string, error)
- func SM3Sum(r io.Reader) (string, error)
- func SM3SumFile(path string) (string, error)
- func SM3SumStr(content string) (string, error)
- func SliceAll[T any](in []T, test func(T) bool) bool
- func SliceAny[T any](in []T, test func(T) bool) bool
- func SliceContains[T comparable](in []T, target T) bool
- func SliceContainsFunc[T any](in []T, target T, equal func(T, T) bool) bool
- func SliceCount[T any](in []T, test func(T) bool) int
- func SliceEach[T any](in []T, fn func(T))
- func SliceEqual[T any](in1 []T, in2 []T, equal func(T, T) bool) bool
- func SliceFilter[T any](in []T, filter func(T) bool) []T
- func SliceFirst[T any](in []T, test func(T) bool) int
- func SliceFlatMap[T any, R any](in []T, convert func(T) []R) []R
- func SliceGroup[T any, K comparable](in []T, getKey func(T) K) map[K][]T
- func SliceLast[T any](in []T, test func(T) bool) int
- func SliceMap[T any, R any](in []T, convert func(T) R) []R
- func SliceNone[T any](in []T, test func(T) bool) bool
- func SliceReduce[T any, R any](in []T, init R, fn func(T, R) R) R
- func SliceSort[T any](in []T, less func(i, j T) bool) []T
- func SliceToMap[T any, K comparable, V any](in []T, getKey func(T) K, getValue func(T) V, combiner func(V, V) V) map[K]V
- func SliceUnique[T comparable](in []T) []T
- func SliceUniqueFunc[T any](in []T, combine func(T, T) T, equal func(T, T) bool) []T
- func VerifyCode[T any](items []T, line func(T) string) string
- func WalkFilesWithMatcher(path string, doneChan <-chan struct{}, ignoreMatcher *pattern_set.PatternSet, ...) (<-chan string, <-chan error)
- func WriteToJSONFile(path string, obj interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MD5SumFile ¶
MD5SumFile returns the MD5 checksum of the given file.
func RemoveEmptyElements ¶
func RemoveEmptyElements[T any](arr []T) []T
RemoveEmptyElements removes empty elements (nil or empty string) from the array and returns the resulting array.
func SHA1SumFile ¶
SHA1SumFile returns the SHA1 checksum of the given file.
func SHA1SumStr ¶
SHA1SumStr returns the SHA1 checksum of the given string.
func SHA256SumFile ¶
SHA256SumFile returns the SHA256 checksum of the given file.
func SHA256SumStr ¶
SHA256SumStr returns the SHA256 checksum of the given string.
func SM3Sum ¶
SM3Sum returns the SM3 checksum of the given reader. The SM3 algorithm is a hash algorithm promulgated by the Chinese government. For details, please refer to https://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002389.shtml
func SM3SumFile ¶
SM3SumFile returns the SM3 checksum of the given file.
func SliceContains ¶
func SliceContains[T comparable](in []T, target T) bool
SliceContains returns true if the slice contains the element.
func SliceContainsFunc ¶
SliceContainsFunc returns true if the slice contains the element using the equal function.
func SliceCount ¶
func SliceEach ¶
func SliceEach[T any](in []T, fn func(T))
SliceEach iterates over the slice and calls the function for each element.
func SliceEqual ¶
SliceEqual returns true if the two slices are equal. The equal function is used to compare the elements.
func SliceFilter ¶
SliceFilter filters the slice using the filter function.
func SliceFirst ¶
SliceFirst returns the index of the first element that matches the test function.
func SliceFlatMap ¶
SliceFlatMap maps the slice using the convert function and flattens the result.
func SliceGroup ¶
func SliceGroup[T any, K comparable](in []T, getKey func(T) K) map[K][]T
SliceGroup groups the slice using the getKey function.
func SliceReduce ¶
SliceReduce reduces the slice to a single value using the init value and the reduce function. The reduce function is called with the current value and the accumulator.
func SliceToMap ¶
func SliceToMap[T any, K comparable, V any](in []T, getKey func(T) K, getValue func(T) V, combiner func(V, V) V) map[K]V
SliceToMap maps the slice using the getKey and getValue functions. If the key is already present, the combiner function is used to combine the values.
func SliceUnique ¶
func SliceUnique[T comparable](in []T) []T
SliceUnique returns a slice with unique elements. The combine function is used to combine the values.
func SliceUniqueFunc ¶
SliceUniqueFunc returns a slice with unique elements. The combine function is used to combine the values. The equal function is used to determine if two elements are equal.
func VerifyCode ¶
VerifyCode returns the verification code(SHA1 checksum) of lines converted from items.
func WalkFilesWithMatcher ¶
func WalkFilesWithMatcher(path string, doneChan <-chan struct{}, ignoreMatcher *pattern_set.PatternSet, hitMatcher *pattern_set.PatternSet) (<-chan string, <-chan error)
WalkFilesWithMatcher walks the file tree rooted at path, sending the paths of all regular files to pathChan. If ignoreMatcher is not nil, files matching the ignoreMatcher will be ignored. If hitMatcher is not nil, only files matching the hitMatcher will be sent to pathChan. If an error is encountered, it will be sent to errChan. If doneChan is closed, the walk process will be canceled.
func WriteToJSONFile ¶
WriteToJSONFile writes the obj to a json file
Types ¶
This section is empty.