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 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 MixUpDisplay(data interface{}, probability float32) string
- func Prepend[T any](slice []T, e T) []T
- func ProtectPanic(ctx context.Context, execFunc func() error) (err error)
- func ReserveSlice[T any](slice []T, capacity int) []T
- 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 WeekRange(t time.Time) (time.Time, time.Time)
- type CIDRChecker
- type Int
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 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 MixUpDisplay ¶
mix up sensitive info to display
func ReserveSlice ¶
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
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