Documentation
¶
Index ¶
- Constants
- func ConvertIntSlice[U, T Int](in []T) (out []U)
- func DayRange(t time.Time) (time.Time, time.Time)
- func DigestDisplay(data interface{}) string
- func Display(data interface{}) string
- func GetNonEmptyStr(s ...string) string
- func IPInCIDR(ipStr, cidrStr string) bool
- func InLocWithSameLiteralTime(t time.Time, loc *time.Location) time.Time
- func InLocWithSameTrueTime(t time.Time, loc *time.Location) time.Time
- func InSlice[T comparable](slice []T, s T) bool
- func IsBlankStr(s string) bool
- func IsBlankStrPtr(s *string) bool
- func IsDigits(s string) bool
- func JsonDeepCopy[T any](v T) *T
- func Marshal(v interface{}) ([]byte, error)
- func MixUpDisplay(data interface{}, probability float32) string
- func MustJsonDecodeString(v string, out interface{})
- func MustJsonEncodeBytes(v interface{}) []byte
- func MustJsonEncodeString(v interface{}) string
- func Prepend[T any](slice []T, e T) []T
- func ProtectPanic(ctx context.Context, execFunc func() error) (err error)
- func Ref[T any](v T) *T
- func ReserveSlice[T any](slice []T, capacity int) []T
- func Retry(ctx context.Context, execFunc func(ctx context.Context) error, ...) error
- func RetryMaxTimes(maxTimes int, interval time.Duration) func(*RetryParams)
- func RetryMaxTimout(retryMaxTimout, interval time.Duration) func(*RetryParams)
- func SplitSlice[T any](slice []T, n int) (ret [][]T)
- func StringMapEqual(lhs, rhs map[string]string) bool
- func TruncateDay(t time.Time) time.Time
- func TruncateWeek(t time.Time) time.Time
- func Unique[T comparable](slice []T) []T
- func Unmarshal(data []byte, v interface{}) error
- func ValueFromRef[T any](v *T) T
- func WeekRange(t time.Time) (time.Time, time.Time)
- type CIDRChecker
- type Int
- type RetryOption
- type RetryParams
Constants ¶
const Day = 24 * time.Hour
Variables ¶
This section is empty.
Functions ¶
func ConvertIntSlice ¶
func ConvertIntSlice[U, T Int](in []T) (out []U)
func Display ¶
func Display(data interface{}) string
display object info, the struct will be convert to json, %+v as the final method, basic type will be use %+v too
func GetNonEmptyStr ¶
func InLocWithSameLiteralTime ¶
InLocWithSameLiteralTime returns a time with the same literal time in the given location. For example, if t is 2019-01-01 00:00:00 +0800 CST, and loc is UTC, then the returned time will be 2019-01-01 00:00:00 +0000 UTC.
func InLocWithSameTrueTime ¶
InLocWithSameTrueTime returns a time with the same true time in the given location. For example, if t is 2019-01-01 00:00:00 +0800 CST, and loc is UTC, then the returned time will be 2019-01-01 08:00:00 +0000 UTC.
func InSlice ¶
func InSlice[T comparable](slice []T, s T) bool
func IsBlankStr ¶
func IsBlankStrPtr ¶
func JsonDeepCopy ¶
func JsonDeepCopy[T any](v T) *T
func MixUpDisplay ¶
mix up sensitive info to display
func MustJsonDecodeString ¶
func MustJsonDecodeString(v string, out interface{})
func MustJsonEncodeBytes ¶
func MustJsonEncodeBytes(v interface{}) []byte
func MustJsonEncodeString ¶
func MustJsonEncodeString(v interface{}) string
func ReserveSlice ¶
func RetryMaxTimes ¶
func RetryMaxTimes(maxTimes int, interval time.Duration) func(*RetryParams)
func RetryMaxTimout ¶
func RetryMaxTimout(retryMaxTimout, interval time.Duration) func(*RetryParams)
func SplitSlice ¶
func StringMapEqual ¶
func TruncateDay ¶
TruncateDay returns the start of the day of the given time.
func TruncateWeek ¶
TruncateWeek returns the start of the week of the given time.
func Unique ¶
func Unique[T comparable](slice []T) []T
func ValueFromRef ¶
func ValueFromRef[T any](v *T) T
Types ¶
type CIDRChecker ¶
type CIDRChecker struct {
// contains filtered or unexported fields
}
func NewCIDRChecker ¶
func NewCIDRChecker(cidrStr string) *CIDRChecker
func (*CIDRChecker) Check ¶
func (self *CIDRChecker) Check(ipStr string) bool
func (*CIDRChecker) String ¶
func (self *CIDRChecker) String() string
type RetryOption ¶
type RetryOption func(*RetryParams)