Documentation ¶
Index ¶
- Variables
- func B2i(b bool) int
- func DayOfWeekCN(n int) string
- func DayOfWeekCN2(n int) string
- func DurationString(d time.Duration) string
- func EndOfDay(t time.Time) time.Time
- func EndOfMonth(t time.Time) time.Time
- func EndOfWeek(t time.Time) time.Time
- func EndOfYear(t time.Time) time.Time
- func FormatDayTime(t time.Time, showSec bool) string
- func FormatFloat(f float64) string
- func GenRSessionID() string
- func GenUSessionID() string
- func GenUUIDV1() string
- func GenUUIDV4() string
- func GenVerifyCodeAny(pool string, width int) string
- func GenVerifyCodeCommon(width int) string
- func GenVerifyCodeNumber(width int) string
- func GetOutboundIP() net.IP
- func HidePhonenumSensitive(s string) string
- func I2b(i int) bool
- func Int64SliceToString(a []int64, delim string) string
- func IntSliceToString(a []int, delim string) string
- func MobileValidate(mm string) bool
- func RangeMonth(t time.Time) []time.Time
- func RangeWeek(t time.Time) []time.Time
- func RangeYear(t time.Time) []time.Time
- func SliceDifference(a []string, b []string) []string
- func SliceIntersection(a []string, b []string) []string
- func SliceUnion(a []string, b []string) []string
- func SliceUniq(a []string) []string
- func SliceUniqInt(a []int) []int
- func SliceUniqInt64(a []int64) []int64
- func SortByKeySF64(m map[string]float64, asc bool) []*datastruct.SF64Pair
- func SortByValueSF64(m map[string]float64, asc bool) []*datastruct.SF64Pair
- func StartOfDay(t time.Time) time.Time
- func StartOfMonth(t time.Time) time.Time
- func StartOfWeek(t time.Time) time.Time
- func StartOfYear(t time.Time) time.Time
- func StringSplit(source string, sep string) []string
- func TraverseTimeRangeByMonth(start time.Time, end time.Time) (pairs []*datastruct.TimePair)
- func TraverseTimeRangeByWeek(start time.Time, end time.Time) (pairs []*datastruct.TimePair)
- func TraverseTimeRangeByYear(start time.Time, end time.Time) (pairs []*datastruct.TimePair)
- func TruncateString(str string, length int) string
- func UrlJoin(host string, subs ...string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNone = "" // no error 没错 ErrBadRequest = "Bad Request" // bad request 错误的请求(参数错误) ErrInternalServerError = "Internal Server Error" // server logic error 服务器内部错误, 服务器自身逻辑问题 ErrInvalidParams = "Invalid Params" // invalid params 参数格式错误 ErrInvalidPassword = "Invalid Password" // invalid password 密码错误 ErrInvalidVerifyCode = "Invalid Verify Code" // invalid verify code 验证码无效 ErrLoginRequired = "Login Required" // need login 需要登录 ErrNotFound = "Not Found" // resource not found 资源不存在 ErrOutOfRange = "Out Of Range" // out of range 越界访问 ErrPermissionDenied = "Permission Denied" // permission denied 权限不足 ErrTooManyRequests = "Too Many Requests" // too many requests 请求过于频繁, 限流 )
Functions ¶
func FormatDayTime ¶
FormatDayTime 按照一天不同的时间段转换成友好的中文描述
func FormatFloat ¶
FormatFloat: float to string, trim tail zero https://stackoverflow.com/questions/31289409/format-a-float-to-n-decimal-places-and-no-trailing-zeros
func GenRSessionID ¶
func GenRSessionID() string
GenRSessionID generate a random session id, most business scene recommand
func GenUUIDV4 ¶
func GenUUIDV4() string
GenUUIDV4 wikipedia said Randomly generated UUIDs have 122 random bits. One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, that means the probability is about 0.00000000006 (6 x 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate.
(most business scene recommand)
func GenVerifyCodeAny ¶
GenVerifyCodeAny generate verify code, get from pool
func GenVerifyCodeCommon ¶
GenVerifyCodeCommon generate verify code, letter + number
func GenVerifyCodeNumber ¶
GenVerifyCodeNumber generate verify code, all is number
func GetOutboundIP ¶
GetOutboundIP get IP address code via https://stackoverflow.com/a/37382208/802815
func HidePhonenumSensitive ¶
HidePhonenumSensitive hide phonenum sensitive info 手机号脱敏
func Int64SliceToString ¶
Int64SliceToString a int64 slice to string Ref: https://stackoverflow.com/questions/37532255/one-liner-to-transform-int-into-string
func IntSliceToString ¶
IntSliceToString a int64 slice to string Ref: https://stackoverflow.com/questions/37532255/one-liner-to-transform-int-into-string
func MobileValidate ¶
func SliceIntersection ¶
SliceIntersection 交集
func SliceUniqInt ¶
func SliceUniqInt64 ¶
func SortByKeySF64 ¶
func SortByKeySF64(m map[string]float64, asc bool) []*datastruct.SF64Pair
SortByKeysSF64 <string, float64> map sort by keys [via]: https://www.geeksforgeeks.org/how-to-sort-golang-map-by-keys-or-values/
func SortByValueSF64 ¶
func SortByValueSF64(m map[string]float64, asc bool) []*datastruct.SF64Pair
SortByValueSF64 <string, float64> map sort by values
func StringSplit ¶
StringSplit string split by `sep` the standard library `Split` when `source` is a empty string, will return a `[""]` slice. In fact, most of time, we want return a length equal 0 slice, `[]`
func TraverseTimeRangeByMonth ¶
TraverseTimeRangeByMonth 在 start ~ end 范围内,以月为单位遍历
func TraverseTimeRangeByWeek ¶
TraverseTimeRangeByWeek 在 start ~ end 范围内,以周为单位遍历
func TraverseTimeRangeByYear ¶
TraverseTimeRangeByYear 在 start ~ end 范围内,以年为单位遍历
func TruncateString ¶
TruncateString Ref: https://dev.to/takakd/go-safe-truncate-string-9h0
Types ¶
This section is empty.