utils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B int64 = 1 << (10 * iota)
	KB
	MB
	GB
	TB
	PB
)

Variables

This section is empty.

Functions

func CheckPath

func CheckPath(path string) (exists bool, isDir bool, err error)

func DetectContentType

func DetectContentType(data []byte, ext string) string

func DirExists

func DirExists(dirPath string) bool

DirExists 判断目录是否存在

func FileExists

func FileExists(path string) bool

FileExists 判断文件是否存在

func IsFile

func IsFile(path string) bool

IsFile 判断是否为文件

func IsMusicExt

func IsMusicExt(ext string) bool

func IsUnique

func IsUnique[T comparable](arr []T) bool

func MD5Hex

func MD5Hex(data []byte) (string, error)

func MkdirIfNotExist

func MkdirIfNotExist(path string, perm os.FileMode) error

func ParseBytes

func ParseBytes(input string) (int64, error)

ParseBytes 将输入字符串转换为字节数

func SplitSlice

func SplitSlice[T any](input []T, chunkSize int) ([][]T, error)

func Ternary

func Ternary[T any](condition bool, trueVal, falseVal T) T

Ternary is a generic function that mimics a ternary expression

func TimeUntilMidnight

func TimeUntilMidnight(timeZone string) (time.Duration, error)

TimeUntilMidnight 计算当前时间到明天零点的时间差

Types

This section is empty.

Jump to

Keyboard shortcuts

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