utils

package
v0.0.0-...-d5a4dd1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BareFilename

func BareFilename(filename string) string

func Base64ToUrlSafe

func Base64ToUrlSafe(b64 string) string

func ByteSizeStr

func ByteSizeStr(b int64) string

func CacheGet

func CacheGet[T any](cache *freecache.Cache, sf *singleflight.Group, key string, fn func() (T, error), ttl int) (T, error)

func CalcContentMD5

func CalcContentMD5(reader io.Reader) (string, error)

func CalcFileContentMD5

func CalcFileContentMD5(filename string) (string, error)

func CalcMultipartFileHeaderContentMD5

func CalcMultipartFileHeaderContentMD5(fh *multipart.FileHeader) (string, error)

func ChangeExtname

func ChangeExtname(filename, extname string) string

func CmdExist

func CmdExist(cmd string) bool

func Coalesce

func Coalesce[T comparable](s ...T) T

func Contains

func Contains[T comparable](item T, list []T) bool

func Convert

func Convert[T, R any](inputs []T, fn func(T) (R, error)) ([]R, error)

func CopyFile

func CopyFile(src, dst string) error

func FileExist

func FileExist(path string) bool

func Map

func Map[T, R any](inputs []T, fn func(T) R) []R

func MustParseInt64

func MustParseInt64(s string) int64

func RandString

func RandString(length int) string

Types

type FileInfo

type FileInfo struct {
	Path  string
	Size  int64
	Mtime int64
}

func ScanFileInDir

func ScanFileInDir(dirPath string) ([]FileInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL