utils

package
v1.9.2802 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(obj interface{}, target interface{}) bool

修改前的 Contains 函数

func ContainsStr

func ContainsStr(slice []string, item string) bool

func CopyFile

func CopyFile(src, dst string) bool

CopyFile 拷贝文件

func CopyPath

func CopyPath(src, dst string) bool

CopyPath 拷贝目录

func CreateDir

func CreateDir(string2 string) error

func DirDot

func DirDot() string

func ExecShell

func ExecShell(shell string, dir string) (stdout string, stderr string)

ExecShell 执行shell命令

func Explode

func Explode(delimiter, datastr string) (arr []string)

Explode 将字符串按字符拆成数组

func FileExists

func FileExists(path string) (bool, error)

func GetCurrentDirectory

func GetCurrentDirectory() string

func GetFileInfo

func GetFileInfo(src string) os.FileInfo

GetFileInfo 获取文件信息

func GetRandStr

func GetRandStr(n int) (randStr string)

func GoId added in v1.9.28

func GoId() string

func IFF

func IFF[T any](yes bool, a, b T) T

IFF if yes return a else b

func IFN

func IFN[T any](yes bool, a, b func() T) T

IFN if yes return func, a() else b().

func LikeContains added in v1.9.20

func LikeContains(obj interface{}, target interface{}) bool

LikeContains 函数,添加了通配符 ** 支持

func LowercaseFirst

func LowercaseFirst(str string) string

func Md5String

func Md5String(str string) string

func Md5ToLower

func Md5ToLower(str string) string

Md5ToLower md5大写

func Md5ToUpper

func Md5ToUpper(str string) string

Md5ToUpper md5小写

func MergeMap

func MergeMap(source map[string][]string, target map[string][]string)

func NewLine

func NewLine() string

func PadLeft

func PadLeft(s string, pad string, plength int) string

func PathExists

func PathExists(path string) (bool, error)

func RemoveFile

func RemoveFile(filePath string) error

func Sha256ToLower added in v1.9.15

func Sha256ToLower(input string) string

Sha256ToLower 方法接收一个字符串输入,生成其对应的 SHA-256 哈希值,并以十六进制字符串形式返回

func Sha256ToUpper added in v1.9.15

func Sha256ToUpper(input string) string

Sha256ToUpper 方法接收一个字符串输入,生成其对应的 SHA-256 哈希值,并以十六进制字符串形式返回

func Substr

func Substr(str string, start int, length int) string

Substr字符串截取

func Try added in v1.9.3

func Try(userFn func(), catchFn func(err interface{}))

Try 捕捉异常

func UppercaseFirst

func UppercaseFirst(str string) string

func WriteFile

func WriteFile(filePath string, content string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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