Documentation ¶
Index ¶
- Variables
- func BCryptCompareHashAndPassword(pwd, hash string) bool
- func BCryptGenerateFromPassword(pwd string) (string, error)
- func ByteString(b []byte) string
- func BytesBufferString(b []byte) string
- func Collect[T any](iter Iterator[T]) []T
- func Compress(b bool) lumberjackOption
- func CronRun(ctx context.Context, corn string, task ...func()) error
- func CronRunM(ctx context.Context, corn string, task ...func()) error
- func DeDuplicate[T comparable](items []T) []T
- func DeDuplicateInPlace[T Numbers](items []T) []T
- func Difference[T comparable](items1, items2 []T) []T
- func DifferenceBoth[T comparable](items1, items2 []T) []T
- func Exists(path string) bool
- func First[T any](objs []T) (T, bool)
- func In[T comparable](e T, items []T) bool
- func InitCert(certPEM, keyPEM []byte) error
- func InitID(workID uint16)
- func InitLogger(level string, w ...io.Writer)
- func Intersection[T comparable](s1, s2 []T) (inter []T)
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsTimeExistIntersection(startTime, endTime time.Time, anotherStartTime, anotherEndTime time.Time) bool
- func IsTimestampExistIntersection(startTime, endTime int64, anotherStartTime, anotherEndTime int64) bool
- func JsonEncode(t any) ([]byte, error)
- func JsonEncodeIndent(t any, prefix, indent string) ([]byte, error)
- func LocalAddr() (string, error)
- func LocalHostname() (string, error)
- func LocalTime(b bool) lumberjackOption
- func LowerTitle(s string) string
- func MaxAge(i int) lumberjackOption
- func MaxBackups(i int) lumberjackOption
- func MaxNumber[T Numbers](e ...T) T
- func MaxSize(i int) lumberjackOption
- func MinNumber[T Numbers](e ...T) T
- func NewLumberjackLogger(fileName string, opts ...lumberjackOption) io.Writer
- func NextID() int64
- func NextStringID() string
- func NotIn[T comparable](e T, items []T) bool
- func Pageination[T any](page, pageSize int, s []T) []T
- func RandNumber(max int64) int64
- func Reduce[T, V any](iter Iterator[V], f Reducer[T, V]) T
- func RemoveInvisibleChars(s string) string
- func RemoveItem[T any](items []T, index int) []T
- func RemoveItemNoOrder[T any](items []T, index int) []T
- func Reverse[T any](items []T)
- func StringByte(s string) []byte
- func StringByteUnsafe(s string) []byte
- func TickerRun(ctx context.Context, d time.Duration, task ...Task) error
- func TickerRunContext(ctx context.Context, d time.Duration, task ...TaskContext) error
- func TickerRunWithStartTimeContext(ctx context.Context, wg *sync.WaitGroup, tm time.Time, d time.Duration, ...) error
- func TimerRun(ctx context.Context, tm time.Time, task ...Task) error
- func TodayZeroTime() time.Time
- func TodayZeroTimestamp() int64
- func VersionInfo() (string, string)
- func ZeroTime(tm time.Time) time.Time
- func ZeroTimestamp(ts int64) int64
- type AESCrypter
- type CTRCrypt
- type Iterator
- type JsonUnmarshal
- type Numbers
- type RSASign
- type Reducer
- type Server
- type ServerOption
- type Signer
- type SliceIterator
- type Task
- type TaskContext
- type TomlUnmarshal
- type UnmarshalConfiger
- type YamlUnmarshal
Constants ¶
This section is empty.
Variables ¶
var ( // Cert is a self signed certificate Cert tls.Certificate // CertPool contains the self signed certificate CertPool *x509.CertPool )
var Logger zerolog.Logger
Functions ¶
func BCryptCompareHashAndPassword ¶
BCryptCompareHashAndPassword true or false
func BCryptGenerateFromPassword ¶
BCryptGenerateFromPassword generate hash from password
func BytesBufferString ¶ added in v0.0.24
BytesBufferString []byte to string
func DeDuplicate ¶ added in v0.0.24
func DeDuplicate[T comparable](items []T) []T
DeDuplicate slice 去重
func DeDuplicateInPlace ¶ added in v0.0.24
func DeDuplicateInPlace[T Numbers](items []T) []T
DeDuplicateInPlace slice 就地去重
func Difference ¶ added in v0.0.24
func Difference[T comparable](items1, items2 []T) []T
Difference 取 items1 中有,而 items2 中没有的
func DifferenceBoth ¶ added in v0.0.24
func DifferenceBoth[T comparable](items1, items2 []T) []T
DifferenceBoth 取 slice1, slice2 的差集
func InitLogger ¶ added in v0.0.24
func Intersection ¶ added in v0.0.24
func Intersection[T comparable](s1, s2 []T) (inter []T)
Intersection 两个 slice 的交集
func IsTimeExistIntersection ¶ added in v0.0.24
func IsTimeExistIntersection(startTime, endTime time.Time, anotherStartTime, anotherEndTime time.Time) bool
IsTimeExistIntersection 两个时间段是否有交集 false 没有交集,true 有交集
func IsTimestampExistIntersection ¶ added in v0.0.24
func IsTimestampExistIntersection(startTime, endTime int64, anotherStartTime, anotherEndTime int64) bool
IsTimestampExistIntersection 两个时间段是否有交集 false 没有交集,true 有交集
func JsonEncode ¶ added in v0.0.27
func JsonEncodeIndent ¶ added in v0.0.27
func LocalHostname ¶ added in v0.0.24
func LowerTitle ¶ added in v0.0.26
func MaxBackups ¶
func MaxBackups(i int) lumberjackOption
func MaxNumber ¶
func MaxNumber[T Numbers](e ...T) T
MaxNumber booleans, numbers, strings, pointers, channels, arrays
func NewLumberjackLogger ¶
func NextStringID ¶ added in v0.0.25
func NextStringID() string
func RandNumber ¶ added in v0.0.25
func RemoveInvisibleChars ¶ added in v0.0.26
func RemoveItem ¶ added in v0.0.24
RemoveItem 移除 slice 中的一个元素
func RemoveItemNoOrder ¶ added in v0.0.24
RemoveItemNoOrder 移除 slice 中的一个元素,无序
func TickerRunContext ¶
TickerRunContext 立即开始以 ticker 的方式执行 task
func TickerRunWithStartTimeContext ¶
func TickerRunWithStartTimeContext(ctx context.Context, wg *sync.WaitGroup, tm time.Time, d time.Duration, task ...TaskContext) error
TickerRunWithStartTimeContext 到达 tm 时间之后,开始以 tikcer 的方式执行 task
func TodayZeroTime ¶
func TodayZeroTimestamp ¶
func TodayZeroTimestamp() int64
func VersionInfo ¶ added in v0.0.27
func ZeroTimestamp ¶
Types ¶
type AESCrypter ¶
type AESCrypter interface { Encrypt(keyString, plainString string) (string, error) Decrypt(keyString, cipherString string) (string, error) }
func NewCTRCrypt ¶
func NewCTRCrypt() AESCrypter
type Iterator ¶ added in v0.0.24
func NewSliceIterator ¶ added in v0.0.24
NewSliceIterator Create an iterator over the slice xs
type JsonUnmarshal ¶
type JsonUnmarshal struct{}
func (*JsonUnmarshal) ReadConfig ¶
func (j *JsonUnmarshal) ReadConfig(p []byte, v any) error
func (*JsonUnmarshal) ReadConfigFromFile ¶
func (j *JsonUnmarshal) ReadConfigFromFile(path string, v any) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server -.
func NewHttpServer ¶
func NewHttpServer(handler http.Handler, opts ...ServerOption) *Server
NewHttpServer -.
type Signer ¶
type Signer interface { Sign(data []byte) ([]byte, error) Verify(data []byte, signature []byte) error }
func NewRSASignFromBytes ¶
func NewRSASignFromFile ¶
type SliceIterator ¶ added in v0.0.24
type SliceIterator[T any] struct { Elements []T // contains filtered or unexported fields }
func (*SliceIterator[T]) Next ¶ added in v0.0.24
func (iter *SliceIterator[T]) Next() bool
Next Move to next value in collection
func (*SliceIterator[T]) Value ¶ added in v0.0.24
func (iter *SliceIterator[T]) Value() T
Value Get current element
type TaskContext ¶
type TomlUnmarshal ¶
type TomlUnmarshal struct{}
func (*TomlUnmarshal) ReadConfig ¶
func (t *TomlUnmarshal) ReadConfig(p []byte, v any) error
func (*TomlUnmarshal) ReadConfigFromFile ¶
func (t *TomlUnmarshal) ReadConfigFromFile(path string, v any) error
type UnmarshalConfiger ¶
type UnmarshalConfiger interface { ReadConfig(p []byte, v any) error ReadConfigFromFile(path string, v any) error }
func NewJsonUnmarshal ¶
func NewJsonUnmarshal() UnmarshalConfiger
func NewTomlUnmarshal ¶
func NewTomlUnmarshal() UnmarshalConfiger
func NewYamlUnmarshal ¶
func NewYamlUnmarshal() UnmarshalConfiger
type YamlUnmarshal ¶
type YamlUnmarshal struct{}
func (*YamlUnmarshal) ReadConfig ¶
func (y *YamlUnmarshal) ReadConfig(p []byte, v any) error
func (*YamlUnmarshal) ReadConfigFromFile ¶
func (y *YamlUnmarshal) ReadConfigFromFile(path string, v any) error