Documentation
¶
Index ¶
- func Base64Decode(s string) ([]byte, error)
- func Base64Encode(data []byte) string
- func CheckStringSize(body string, sizeLimit int64) error
- func ErrorContains(err error, substr string) bool
- func Panic(err error)
- func PathIsExist(name string) bool
- func PathIsNotExist(name string) (ok bool)
- func RandomID() string
- func RemoveIfExist(name string) (err error)
- func StringLimit(s string, limit int) string
- func TimeNow() int64
- func WrapErrors(allErrors ...error) (wrapped error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckStringSize ¶
func ErrorContains ¶
ErrorContains returns NoCaseContains(err.Error(), substr) Returns false if err is nil.
func PathIsNotExist ¶
func RandomID ¶
func RandomID() string
RandomID 返回一个上升趋势的随机 id, 由时间戳与随机数组成。 时间戳确保其上升趋势(大致有序),随机数确保其随机性(防止被穷举, 防冲突)。 RandomID 考虑了 “生成 id 的速度”、 “并发防冲突” 与 “id 长度” 这三者的平衡,适用于大多数中、小规模系统(当然,不适用于大型系统)。
func RemoveIfExist ¶
func StringLimit ¶
StringLimit 截取 s, 确保 s 不大于 limit. 同时会确保截取后的 s 是有效的 utf8 字符串.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.