Versions in this module Expand all Collapse all v0 v0.0.1 Nov 28, 2024 Changes in this version + const GB + const KB + const MB + const TB + var CNLoc = time.FixedZone("UTC", 8 * 60 * 60) + var DEC = map[string]string + var ErrUnsupported = errors.New("hash type not supported") + var IoBuffPool = &sync.Pool + var Json = json.ConfigCompatibleWithStandardLibrary + var Log = log.New() + var MD5 = RegisterHash("md5", "MD5", 32, md5.New) + var SHA1 = RegisterHash("sha1", "SHA-1", 40, sha1.New) + var SHA256 = RegisterHash("sha256", "SHA-256", 64, sha256.New) + var Supported []*HashType + func ClientIP(r *http.Request) string + func CopyDir(src, dst string) error + func CopyFile(src, dst string) error + func CopyWithBuffer(dst io.Writer, src io.Reader) (written int64, err error) + func CopyWithBufferN(dst io.Writer, src io.Reader, n int64) (written int64, err error) + func CopyWithCtx(ctx context.Context, out io.Writer, in io.Reader, size int64, ...) error + func CreateNestedDirectory(path string) error + func CreateNestedFile(path string) (*os.File, error) + func CreateTempFile(r io.Reader, size int64) (*os.File, error) + func EncodePath(path string, all ...bool) string + func Exists(name string) bool + func Ext(path string) string + func FixAndCleanPath(path string) string + func GetActualMountPath(mountPath string) string + func GetFileType(filename string) int + func GetFullPath(mountPath, path string) string + func GetMD5EncodeStr(data string) string + func GetMimeType(name string) string + func GetNoneEmpty(strArr ...string) string + func GetObjType(filename string, isDir bool) int + func HashData(hashType *HashType, data []byte, params ...any) string + func HashFile(hashType *HashType, file io.ReadSeeker, params ...any) (string, error) + func HashReader(hashType *HashType, reader io.Reader, params ...any) (string, error) + func InjectQuery(raw string, query url.Values) (string, error) + func IsBalance(str string) bool + func IsBool(bs ...bool) bool + func IsCanceled(ctx context.Context) bool + func IsEmailFormat(email string) bool + func IsLocalIP(ip net.IP) bool + func IsLocalIPAddr(ip string) bool + func IsSubPath(path string, subPath string) bool + func JoinBasePath(basePath, reqPath string) (string, error) + func LimitWriter(w io.Writer, limit int64) io.Writer + func MappingName(name string) string + func Max[T constraints.Ordered](a, b T) T + func MergeErrors(errs ...error) error + func MergeMap(mObj ...map[string]interface{}) map[string]interface + func Min[T constraints.Ordered](a, b T) T + func MustParseCNTime(str string) time.Time + func MustSliceConvert[S any, D any](srcS []S, convert func(src S) D) []D + func NewDebounce(interval time.Duration) func(f func()) + func NewDebounce2(interval time.Duration, f func()) func() + func NewLimitReadCloser(reader io.Reader, close CloseFunc, limit int64) io.ReadCloser + func NewReadCloser(reader io.Reader, close CloseFunc) io.ReadCloser + func NewThrottle(interval time.Duration) func(func()) + func NewThrottle2(interval time.Duration, fn func()) func() + func PathAddSeparatorSuffix(path string) string + func PathEqual(path1, path2 string) bool + func Retry(attempts int, sleep time.Duration, f func() error) (err error) + func SafeAtob(data string) (string, error) + func SliceAllContains[T comparable](arr []T, vs ...T) bool + func SliceContains[T comparable](arr []T, v T) bool + func SliceConvert[S any, D any](srcS []S, convert func(src S) (D, error)) ([]D, error) + func SliceEqual[T comparable](a, b []T) bool + func SliceFilter[T any](arr []T, filter func(src T) bool) []T + func SliceMeet[T1, T2 any](arr []T1, v T2, meet func(item T1, v T2) bool) bool + func SliceReplace[T any](arr []T, replace func(src T) T) + func SymlinkOrCopyFile(src, dst string) error + func TokenSource(fn func() (*oauth2.Token, error)) oauth2.TokenSource + func WriteJsonToFile(dst string, data interface{}, std ...bool) bool + type CloseFunc func() error + func (c CloseFunc) Close() error + type Closers struct + func EmptyClosers() Closers + func NewClosers(c ...io.Closer) Closers + func (c *Closers) Add(closer io.Closer) + func (c *Closers) AddClosers(closers Closers) + func (c *Closers) Close() error + func (c *Closers) GetClosers() Closers + type ClosersIF interface + Add func(closer io.Closer) + AddClosers func(closers Closers) + GetClosers func() Closers + type HashInfo struct + func FromString(str string) HashInfo + func NewHashInfo(ht *HashType, str string) HashInfo + func NewHashInfoByMap(h map[*HashType]string) HashInfo + func (hi HashInfo) Export() map[*HashType]string + func (hi HashInfo) GetHash(ht *HashType) string + func (hi HashInfo) String() string + type HashType struct + Alias string + Name string + NewFunc func(...any) hash.Hash + Width int + func RegisterHash(name, alias string, width int, newFunc func() hash.Hash) *HashType + func RegisterHashWithParam(name, alias string, width int, newFunc func(...any) hash.Hash) *HashType + func (ht *HashType) MarshalJSON() ([]byte, error) + func (ht *HashType) MarshalText() (text []byte, err error) + type MultiHasher struct + func NewMultiHasher(types []*HashType) *MultiHasher + func (m *MultiHasher) GetHashInfo() *HashInfo + func (m *MultiHasher) Size() int64 + func (m *MultiHasher) Sum(hashType *HashType) ([]byte, error) + func (m *MultiHasher) Write(p []byte) (n int, err error) + type MultiReadable struct + func NewMultiReadable(reader io.Reader) *MultiReadable + func (mr *MultiReadable) Close() error + func (mr *MultiReadable) Read(p []byte) (int, error) + func (mr *MultiReadable) Reset() error + type ReadCloser struct