Version: v0.0.0-...-bb0c7ea Latest Latest

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 21 Imported by: 0




This section is empty.


This section is empty.


func AlmostEqual

func AlmostEqual(a, b float64) bool

AlmostEqual returns true is abs(a - b) < 1e-6

func ChinaNow

func ChinaNow() (time.Time, error)

ChinaNow 获取中国时间

func ChinaToday

func ChinaToday() (time.Time, error)

ChinaToday 获取中国时间当天的起始时间

func ChinaYesterday

func ChinaYesterday() (time.Time, error)

ChinaYesterday 获取中国时间昨天的起始时间

func ContainsAny

func ContainsAny(targets []string, checkArr []string) bool

ContainsAny 判断该字符串数据是否包含其中任意一个字符串

func ContainsString

func ContainsString(arr []string, str string) (found bool)

ContainsString 判断字符串数组是否包含该字符串

func CutRune

func CutRune(str string, max int) string

CutRune 按rune截断字符串

func FormatTime

func FormatTime(t time.Time) string

FormatTime 格式化时间为字符串RFC3339

func GenXID

func GenXID() string

GenXID 生成xid

func GetFirstLetter

func GetFirstLetter(str string) string

GetFirstLetter 获取字符串首字母

func GetMockTime

func GetMockTime() string

GetMockTime 获取mock的时间

func GetSessionID

func GetSessionID(c *elton.Context) string

GetSessionID 获取session id

func GetStack

func GetStack(max int) []string

GetStack 获取调用信息

func GetTrackID

func GetTrackID(c *elton.Context) string

GetTrackID 获取track id

func IsBetween

func IsBetween(begin, end time.Time) bool

IsBetween 判断当前时间是否在开始与结束时间之间

func IsDevelopment

func IsDevelopment() bool

IsDevelopment 判断是否开发环境

func IsProduction

func IsProduction() bool

IsProduction 判断是否生产环境

func IsTest

func IsTest() bool

IsTest 判断是否测试环境

func MergeMapStringInterface

func MergeMapStringInterface(target map[string]interface{}, sources ...map[string]interface{}) map[string]interface{}

MergeMapStringInterface 合并map[string]interface{}

func NewTimeWithRandomNS

func NewTimeWithRandomNS(timestamp int64) time.Time

NewTimeWithRandomNS 根据timestamp并添加随机的ns生成时间

func Now

func Now() time.Time

Now 获取当前时间(测试环境允许使用mock的时间)

func NowString

func NowString() string

NowString 获取当前时间字符串RFC3339

func ParseTime

func ParseTime(str string) (time.Time, error)

ParseTime 字符串转换为时间,字符串为RFC3339格式

func RandomDigit

func RandomDigit(n int) string

RandomDigit 创建指定长度的数字字符串

func RandomString

func RandomString(n int) string

RandomString 创建指定长度的字符串

func SetMockTime

func SetMockTime(v string)

SetMockTime 设置mock的时间

func Sha256

func Sha256(str string) string

Sha256 对字符串做sha256后返回base64字符串

func ToFixed

func ToFixed(value float64, precision int) string

ToFixed formats float64 to string

func UTCNow

func UTCNow() time.Time

UTCNow 获取UTC的时间

func UTCNowString

func UTCNowString() string

UTCNowString 获取UTC时间字符串RFC3339


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto