utls

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nanosecond  = int64(time.Nanosecond) // Nanosecond
	Microsecond = 1000 * Nanosecond      // Nanosecond
	Millisecond = 1000 * Microsecond     // Nanosecond
	Second      = 1000 * Millisecond     // Nanosecond
	Minute      = 60 * Second            // Nanosecond
	Hour        = 60 * Minute            // Nanosecond
	Day         = 24 * Hour              // Nanosecond
	Year        = 365 * Day              // Nanosecond

	SecondsPerYear   = Year / Second   // Second
	SecondsPerDay    = Day / Second    // Second
	SecondsPerHour   = Hour / Second   // Second
	SecondsPerMinute = Minute / Second // Second

	MillisecondsPerYear   = Year / Millisecond   // Millisecond
	MillisecondsPerDay    = Day / Millisecond    // Millisecond
	MillisecondsPerHour   = Hour / Millisecond   // Millisecond
	MillisecondsPerMinute = Minute / Millisecond // Millisecond
	MillisecondsPerSecond = Second / Millisecond // Millisecond

	MicrosecondsPerYear        = Year / Microsecond        // Microsecond
	MicrosecondsPerDay         = Day / Microsecond         // Microsecond
	MicrosecondsPerHour        = Hour / Microsecond        // Microsecond
	MicrosecondsPerMinute      = Minute / Microsecond      // Microsecond
	MicrosecondsPerSecond      = Second / Microsecond      // Microsecond
	MicrosecondsPerMillisecond = Millisecond / Microsecond // Microsecond
)

Variables

This section is empty.

Functions

func Bts2Str

func Bts2Str(bts []byte) string

func CheckIfUseLCSByIdc

func CheckIfUseLCSByIdc(idc string) bool

根据idc判断是否启用LCS服务

func ConvertToInt64

func ConvertToInt64(v interface{}) (int64, error)

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. copy the file contents from src to dst.

func CutStringSliceByStep

func CutStringSliceByStep(array []string, step int) (int, [][]string)

return subslice count and subslices

func DGetCurrentTime

func DGetCurrentTime(layout string) string

func Dump

func Dump(fileDir, name string) (*os.File, error)

func Dup2 added in v1.7.2

func Dup2(from int, to int) error

func Duration

func Duration(d int64) time.Duration

func EnsureDir

func EnsureDir(dir string) error

func Exists

func Exists(p string) bool

func FatalWithSmsAlert added in v1.6.6

func FatalWithSmsAlert(errMsg string)

func FixCategoryByIdc

func FixCategoryByIdc(idc, category string) string

LCS服务为防止无法寻找到topic,需要对category添加前缀

func FromLocalDateToSecond

func FromLocalDateToSecond(v string) int64

func FromSecondToLocalDate

func FromSecondToLocalDate(v int64) string

func FromTime2TimeInt

func FromTime2TimeInt(t time.Time) int

func FuncName

func FuncName(skip int) string

func GetCurrentMicrosecond

func GetCurrentMicrosecond() int64

func GetCurrentMillisecond

func GetCurrentMillisecond() int64

func GetCurrentNanosecond

func GetCurrentNanosecond() int64

func GetCurrentSecond

func GetCurrentSecond() int64

func GetCurrentTime

func GetCurrentTime() string

func HumanSize

func HumanSize(s uint64) string

func Int64ArraySlice

func Int64ArraySlice(array []int64, offset int, length int) []int64

func Int64ArrayToString

func Int64ArrayToString(list []int64, sep string) string

func IsEmpty

func IsEmpty(dir string) (bool, error)
func IsLink(p string) (bool, error)

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

func IsSameDayWithTimestamp

func IsSameDayWithTimestamp(d1, d2 int64) bool

func IsTimeoutError added in v1.6.6

func IsTimeoutError(err error) bool

func ListDir

func ListDir(dir string) ([]string, error)

func LoadJsonToObject

func LoadJsonToObject(filename string, t interface{}) error

func Marshal

func Marshal(v interface{}) ([]byte, error)

no escape html

func MustFloat64

func MustFloat64(v interface{}, defaultValue float64) float64

func MustInt64

func MustInt64(v interface{}, defaultValue int64) int64

func MustInt64Array

func MustInt64Array(v interface{}, defaultValue []int64) []int64

func MustString

func MustString(v interface{}, defaultValue string) string

func MustStringArray

func MustStringArray(v interface{}, defaultValue []string) []string

func ParseMemorySize

func ParseMemorySize(size string) (uint64, error)

k, m, g

func PathExists

func PathExists(path string) bool

func RandString

func RandString(n int) string

func ReviewDumpPanic

func ReviewDumpPanic(file *os.File) error

func SafeSprintf

func SafeSprintf(format string, args ...interface{}) string

func Sleep

func Sleep(millisecond int64)

func SliceCutter

func SliceCutter(v interface{}, maxsize int) ([]interface{}, error)

func SplitTimeInt

func SplitTimeInt(t int) (year, month, day int)

func Store2File

func Store2File(file string, content string) error

func Str2Bts

func Str2Bts(str string) []byte

func StringArraySlice

func StringArraySlice(array []string, offset int, length int) []string

func StringInSlice added in v1.6.6

func StringInSlice(a []string, s string) bool

func StringStringMap2StringInterfaceMap

func StringStringMap2StringInterfaceMap(input map[string]string) map[string]interface{}

This is a safe convert since string can always convert to interface{}

func TraceId added in v1.6.3

func TraceId() string

func TryString

func TryString(v interface{}) (string, bool)

func WithRecover

func WithRecover(fn func(), errHandler func(interface{})) (err interface{})

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