FlyUtils

package
v0.0.0-...-482d8b5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRoot

func CheckRoot() bool

检查是否是root用户运行

func Empty

func Empty(obj any) bool

判断变量是否为空

func FileExists

func FileExists(path string) bool

判断文件是否存在

func GetAppRootDir

func GetAppRootDir() string

获取程序所在文件夹

func GetWorkDir

func GetWorkDir() string

获取工作目录

func IsEmptyDir

func IsEmptyDir(dirname string) bool

判断目录是否为空

func ListDir

func ListDir(dirPth string) (files []string, files1 []string, err error)

获取指定目录下的所有文件和目录

func MD5

func MD5(str string) string

func MD5File

func MD5File(path string) (string, error)

func RandomString

func RandomString(length int) string

func ReadFile

func ReadFile(filename string) ([]byte, error)

读取所有文件

func ReadFile2str

func ReadFile2str(filename string) string

读取文件到字符串,失败返回空字符串

func Sleep

func Sleep(ms int)

func StringSplit

func StringSplit(s string, sep string) []string

分割字符串,并且去掉空格和空元素

func StringSplitFloat64

func StringSplitFloat64(s string, sep string) []float64

分割字符串,并且去掉空格和空元素,转化成float64

func StringSplitInt64

func StringSplitInt64(s string, sep string) []int64

分割字符串,并且去掉空格和空元素,转化成int64

func StringToDate

func StringToDate(s string) (time.Time, error)

StringToDate attempts to parse a string into a time.Time type using a predefined list of formats. If no suitable format is found, an error is returned.

func StringToDateInDefaultLocation

func StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error)

StringToDateInDefaultLocation casts an empty interface to a time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.

func Timestamp

func Timestamp() int64

func Timestamp_ms

func Timestamp_ms() int64

func Timestamp_ns

func Timestamp_ns() int64

func ToBool

func ToBool(i interface{}) bool

ToBool casts an interface to a bool type.

func ToBoolE

func ToBoolE(i interface{}) (bool, error)

ToBoolE casts an interface to a bool type.

func ToBoolSlice

func ToBoolSlice(i interface{}) []bool

ToBoolSlice casts an interface to a []bool type.

func ToBoolSliceE

func ToBoolSliceE(i interface{}) ([]bool, error)

ToBoolSliceE casts an interface to a []bool type.

func ToDuration

func ToDuration(i interface{}) time.Duration

ToDuration casts an interface to a time.Duration type.

func ToDurationE

func ToDurationE(i interface{}) (d time.Duration, err error)

ToDurationE casts an interface to a time.Duration type.

func ToDurationSlice

func ToDurationSlice(i interface{}) []time.Duration

ToDurationSlice casts an interface to a []time.Duration type.

func ToDurationSliceE

func ToDurationSliceE(i interface{}) ([]time.Duration, error)

ToDurationSliceE casts an interface to a []time.Duration type.

func ToFloat32

func ToFloat32(i interface{}) float32

ToFloat32 casts an interface to a float32 type.

func ToFloat32E

func ToFloat32E(i interface{}) (float32, error)

ToFloat32E casts an interface to a float32 type.

func ToFloat64

func ToFloat64(i interface{}) float64

ToFloat64 casts an interface to a float64 type.

func ToFloat64E

func ToFloat64E(i interface{}) (float64, error)

ToFloat64E casts an interface to a float64 type.

func ToInt

func ToInt(i interface{}) int

ToInt casts an interface to an int type.

func ToInt16

func ToInt16(i interface{}) int16

ToInt16 casts an interface to an int16 type.

func ToInt16E

func ToInt16E(i interface{}) (int16, error)

ToInt16E casts an interface to an int16 type.

func ToInt32

func ToInt32(i interface{}) int32

ToInt32 casts an interface to an int32 type.

func ToInt32E

func ToInt32E(i interface{}) (int32, error)

ToInt32E casts an interface to an int32 type.

func ToInt64

func ToInt64(i interface{}) int64

ToInt64 casts an interface to an int64 type.

func ToInt64E

func ToInt64E(i interface{}) (int64, error)

ToInt64E casts an interface to an int64 type.

func ToInt8

func ToInt8(i interface{}) int8

ToInt8 casts an interface to an int8 type.

func ToInt8E

func ToInt8E(i interface{}) (int8, error)

ToInt8E casts an interface to an int8 type.

func ToIntE

func ToIntE(i interface{}) (int, error)

ToIntE casts an interface to an int type.

func ToIntSlice

func ToIntSlice(i interface{}) []int

ToIntSlice casts an interface to a []int type.

func ToIntSliceE

func ToIntSliceE(i interface{}) ([]int, error)

ToIntSliceE casts an interface to a []int type.

func ToSlice

func ToSlice(i interface{}) []interface{}

ToSlice casts an interface to a []interface{} type.

func ToSliceE

func ToSliceE(i interface{}) ([]interface{}, error)

ToSliceE casts an interface to a []interface{} type.

func ToString

func ToString(i interface{}) string

ToString casts an interface to a string type.

func ToStringE

func ToStringE(i interface{}) (string, error)

ToStringE casts an interface to a string type.

func ToStringMap

func ToStringMap(i interface{}) map[string]interface{}

ToStringMap casts an interface to a map[string]interface{} type.

func ToStringMapBool

func ToStringMapBool(i interface{}) map[string]bool

ToStringMapBool casts an interface to a map[string]bool type.

func ToStringMapBoolE

func ToStringMapBoolE(i interface{}) (map[string]bool, error)

ToStringMapBoolE casts an interface to a map[string]bool type.

func ToStringMapE

func ToStringMapE(i interface{}) (map[string]interface{}, error)

ToStringMapE casts an interface to a map[string]interface{} type.

func ToStringMapInt

func ToStringMapInt(i interface{}) map[string]int

ToStringMapInt casts an interface to a map[string]int type.

func ToStringMapInt64

func ToStringMapInt64(i interface{}) map[string]int64

ToStringMapInt64 casts an interface to a map[string]int64 type.

func ToStringMapInt64E

func ToStringMapInt64E(i interface{}) (map[string]int64, error)

ToStringMapInt64E casts an interface to a map[string]int64{} type.

func ToStringMapIntE

func ToStringMapIntE(i interface{}) (map[string]int, error)

ToStringMapIntE casts an interface to a map[string]int{} type.

func ToStringMapString

func ToStringMapString(i interface{}) map[string]string

ToStringMapString casts an interface to a map[string]string type.

func ToStringMapStringE

func ToStringMapStringE(i interface{}) (map[string]string, error)

ToStringMapStringE casts an interface to a map[string]string type.

func ToStringMapStringSlice

func ToStringMapStringSlice(i interface{}) map[string][]string

ToStringMapStringSlice casts an interface to a map[string][]string type.

func ToStringMapStringSliceE

func ToStringMapStringSliceE(i interface{}) (map[string][]string, error)

ToStringMapStringSliceE casts an interface to a map[string][]string type.

func ToStringSlice

func ToStringSlice(i interface{}) []string

ToStringSlice casts an interface to a []string type.

func ToStringSliceE

func ToStringSliceE(i interface{}) ([]string, error)

ToStringSliceE casts an interface to a []string type.

func ToTime

func ToTime(i interface{}) time.Time

ToTime casts an interface to a time.Time type.

func ToTimeE

func ToTimeE(i interface{}) (tim time.Time, err error)

ToTimeE casts an interface to a time.Time type.

func ToTimeInDefaultLocation

func ToTimeInDefaultLocation(i interface{}, location *time.Location) time.Time

func ToTimeInDefaultLocationE

func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error)

ToTimeInDefaultLocationE casts an empty interface to time.Time, interpreting inputs without a timezone to be in the given location, or the local timezone if nil.

func ToUint

func ToUint(i interface{}) uint

ToUint casts an interface to a uint type.

func ToUint16

func ToUint16(i interface{}) uint16

ToUint16 casts an interface to a uint16 type.

func ToUint16E

func ToUint16E(i interface{}) (uint16, error)

ToUint16E casts an interface to a uint16 type.

func ToUint32

func ToUint32(i interface{}) uint32

ToUint32 casts an interface to a uint32 type.

func ToUint32E

func ToUint32E(i interface{}) (uint32, error)

ToUint32E casts an interface to a uint32 type.

func ToUint64

func ToUint64(i interface{}) uint64

ToUint64 casts an interface to a uint64 type.

func ToUint64E

func ToUint64E(i interface{}) (uint64, error)

ToUint64E casts an interface to a uint64 type.

func ToUint8

func ToUint8(i interface{}) uint8

ToUint8 casts an interface to a uint8 type.

func ToUint8E

func ToUint8E(i interface{}) (uint8, error)

ToUint8E casts an interface to a uint type.

func ToUintE

func ToUintE(i interface{}) (uint, error)

ToUintE casts an interface to a uint type.

func Trim

func Trim(strs ...string) string

支持多字符连续处理的trim

func ValBool

func ValBool(obj any) bool

判断是否是布尔真值,支持字符串的true和false等写法

func ValFindInArray

func ValFindInArray(array any, val any) int

反射方式获取变量是否在数组中,如果存在返回索引,不存在返回-1

func ValFloat32

func ValFloat32(obj any, defaults ...float32) float32

将任意类型强制转成float32

func ValFloat64

func ValFloat64(obj any, defaults ...float64) float64

将任意类型强制转成float64

func ValIf

func ValIf(condition bool, trueVal, falseVal any) any

三元运算符hack

func ValInArray

func ValInArray(array any, val any) bool

反射方式获取变量是否在数组中

func ValInt

func ValInt(obj any, defaults ...int) int

转换为int型

func ValInt64

func ValInt64(obj any, defaults ...int64) int64

转换为int型

func ValIsBlank

func ValIsBlank(value reflect.Value) bool

func ValString

func ValString(obj any, defaults ...string) string

转换为string型

func WaitExit

func WaitExit()

func WriteFile4byte

func WriteFile4byte(filename string, data *[]byte) error

func WriteFile4byteAppend

func WriteFile4byteAppend(filename string, data *[]byte) error

写文件,追加

func WriteFile4str

func WriteFile4str(filename string, data string) error

写文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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