Documentation ¶
Index ¶
- Variables
- func ClientIP(r *http.Request) string
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) 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.ReadCloser) (*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 GetMD5Encode(data []byte) string
- func GetMD5EncodeStr(data string) string
- func GetMimeType(name string) string
- func GetObjType(filename string, isDir bool) int
- func GetSHA1Encode(data []byte) string
- func GetSHA256Encode(data []byte) string
- 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 LimitRateReflect(f interface{}, interval time.Duration) func(...interface{}) []interface{}
- func LimitWriter(w io.Writer, size int64) io.Writer
- func MappingName(name string) string
- func MergeErrors(errs ...error) error
- func MergeMap(mObj ...map[string]interface{}) map[string]interface{}
- 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 PathAddSeparatorSuffix(path string) string
- func PathEqual(path1, path2 string) bool
- func SafeAtob(data string) (string, error)
- 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 SliceMeet[T1, T2 any](arr []T1, v T2, meet func(item T1, v T2) bool) bool
- func SymlinkOrCopyFile(src, dst string) error
- func WriteJsonToFile(dst string, data interface{}, std ...bool) bool
- type CloseFunc
- type Fn
- type FnCtx
- type MultiReadable
- type ReadCloser
Constants ¶
This section is empty.
Variables ¶
var DEC = map[string]string{
"-": "+",
"_": "/",
".": "=",
}
var Json = json.ConfigCompatibleWithStandardLibrary
var Log = log.New()
Functions ¶
func CopyWithCtx ¶
func CopyWithCtx(ctx context.Context, out io.Writer, in io.Reader, size int64, progress func(percentage int)) error
CopyWithCtx slightly modified function signature: - context has been added in order to propagate cancelation - I do not return the number of bytes written, has it is not useful in my use case
func CreateNestedDirectory ¶ added in v3.11.0
CreateNestedDirectory create nested directory
func CreateNestedFile ¶
CreateNestedFile create nested file
func CreateTempFile ¶
func CreateTempFile(r io.ReadCloser) (*os.File, error)
CreateTempFile create temp file from io.ReadCloser, and seek to 0
func EncodePath ¶
func FixAndCleanPath ¶ added in v3.7.1
FixAndCleanPath The upper layer of the root directory is still the root directory. So ".." And "." will be cleared for example 1. ".." or "." => "/" 2. "../..." or "./..." => "/..." 3. "../.x." or "./.x." => "/.x." 4. "x//\\y" = > "/z/x"
func GetActualMountPath ¶ added in v3.7.1
GetActualMountPath remove balance suffix
func GetFullPath ¶ added in v3.9.0
func GetMD5Encode ¶
func GetMD5EncodeStr ¶ added in v3.22.0
func GetMimeType ¶ added in v3.2.0
func GetObjType ¶ added in v3.6.0
func GetSHA1Encode ¶
func GetSHA256Encode ¶ added in v3.11.0
func IsCanceled ¶
func IsEmailFormat ¶ added in v3.4.0
func IsLocalIPAddr ¶
func JoinBasePath ¶ added in v3.6.0
func LimitRateReflect ¶ added in v3.17.0
func MappingName ¶ added in v3.5.1
func MergeErrors ¶ added in v3.7.1
func MustParseCNTime ¶ added in v3.4.0
func MustSliceConvert ¶ added in v3.6.0
func NewDebounce ¶ added in v3.9.0
func NewDebounce2 ¶ added in v3.9.0
func NewLimitReadCloser ¶ added in v3.12.0
func NewReadCloser ¶ added in v3.12.0
func NewReadCloser(reader io.Reader, close CloseFunc) io.ReadCloser
func PathAddSeparatorSuffix ¶ added in v3.7.1
PathAddSeparatorSuffix Add path '/' suffix for example /root => /root/
func SliceContains ¶
func SliceContains[T comparable](arr []T, v T) bool
SliceContains check if slice contains element
func SliceConvert ¶
SliceConvert convert slice to another type slice
func SliceEqual ¶
func SliceEqual[T comparable](a, b []T) bool
SliceEqual check if two slices are equal
func SymlinkOrCopyFile ¶ added in v3.11.0
SymlinkOrCopyFile symlinks a file or copy if symlink failed
func WriteJsonToFile ¶
WriteJsonToFile write struct to json file
Types ¶
type MultiReadable ¶ added in v3.15.1
type MultiReadable struct {
// contains filtered or unexported fields
}
func NewMultiReadable ¶ added in v3.15.1
func NewMultiReadable(reader io.Reader) *MultiReadable
func (*MultiReadable) Close ¶ added in v3.15.1
func (mr *MultiReadable) Close() error
func (*MultiReadable) Reset ¶ added in v3.15.1
func (mr *MultiReadable) Reset() error