Documentation ¶
Index ¶
- Constants
- Variables
- func Apply(f interface{}, args []interface{}) []reflect.Value
- func Binary2Byte(in string) uint8
- func Binary2Short(in string) uint16
- func CheckDuplicate(slice interface{}) bool
- func CheckDuplicateString(slice []string) bool
- func CheckTimeFormat(src, layout string) bool
- func ConfDecode(out interface{}, str string) error
- func ConfFormat(str string) string
- func CreateFile(filePath string, perms ...int) error
- func CurrentPath() (string, error)
- func DigitalNum(num int) int
- func DigitalToString(num int, digital int) string
- func ExecPath() (string, error)
- func ExternalIP() (net.IP, error)
- func FilterFileWithExt(files []string, ext ...string) []string
- func FilterFileWithFunc(files []string, f func(string) bool) []string
- func FindFile(dirPath string, name string, recursive bool) string
- func FormatTimeToDayString(time time.Time) string
- func FormatTimeToISOString(time time.Time) string
- func FormatTimeToMonthString(time time.Time) string
- func FormatTimeToString(time time.Time) string
- func FormatTimeToYearString(time time.Time) string
- func GetCurrentDirectory() string
- func GetDateNoOffset(t time.Time) string
- func GetDateWithOffset(t time.Time, offset time.Duration) string
- func GetDayStart(t time.Time) time.Time
- func GetDaysOfMonth(t time.Time) int
- func GetGoroutineID() uint64
- func GetIpFromAddr(addr net.Addr) net.IP
- func GetLastDayOfMonth(t time.Time) time.Time
- func GetLastDaysOfMonth(t time.Time, days int) time.Time
- func GetLastWeekDay(t time.Time, weekday time.Weekday) time.Time
- func GetMonthDayByLastWeekDay(t time.Time, weekday time.Weekday) int
- func GetMonthStart(t time.Time) time.Time
- func GetMonthStartEnd(t time.Time) (time.Time, time.Time)
- func GetNextDayStart(t time.Time) time.Time
- func GetNextMonthStart(t time.Time) time.Time
- func GetNextMonthsStart(t time.Time, months int) time.Time
- func GetNextYearStart(t time.Time) time.Time
- func GetNowDateWithOffset(offset time.Duration) string
- func GetParentDirectory(dir string) string
- func GetPassedDays(tm1, tm2 time.Time) int64
- func GetPublicIp() string
- func GetTimeFromMs(t int64) time.Time
- func GetTimeWithOffset(t time.Time, offset time.Duration) time.Time
- func GetWeekDay(date time.Time, weekday time.Weekday) time.Time
- func GetYearStart(t time.Time) time.Time
- func HasReflectTypeInSlice(slice []reflect.Type, v interface{}) bool
- func IsAndroid() bool
- func IsBool(i interface{}) bool
- func IsDarwin() bool
- func IsEqual(a interface{}, b interface{}) bool
- func IsFileExist(path string) bool
- func IsFileModified(filePath string) bool
- func IsFileWithExt(p string, ext string) bool
- func IsFreeBSD() bool
- func IsIOS() bool
- func IsInt(i interface{}) bool
- func IsLinux() bool
- func IsMac() bool
- func IsNil(i interface{}) bool
- func IsNilPointer(c interface{}) bool
- func IsOSX() bool
- func IsProcessExist(s string) bool
- func IsString(i interface{}) bool
- func IsToday(ts int64) bool
- func IsWeb() bool
- func IsWindows() bool
- func LoadJson(path string, v interface{})
- func LoadRSAPrivateKeyPem(p string) (*rsa.PrivateKey, error)
- func LoadRSAPublicKeyPem(p string) (*rsa.PublicKey, error)
- func MilliSecondToString(millisec int64) string
- func Nil[T any]() T
- func PathExists(path string) (bool, error)
- func Recover(r interface{}, all bool) error
- func RemoveMapElement[T1 comparable, T2 comparable](obj map[T1]T2, elem T2) map[T1]T2
- func RemoveMapWithCondition[T1 comparable, T2 any](obj map[T1]T2, f func(key T1, elem T2) bool) map[T1]T2
- func ReplaceTextParams(text string, params ...interface{}) string
- func SameDay(a, b time.Time) bool
- func Sleep(ms int64)
- func SleepUtil(ms int64, f func() bool)
- func Struct2Map(s interface{}, fields ...string) (map[string]interface{}, error)
- func Ternary[T any](expr bool, whenTrue, whenFalse T) T
- func Time2TenYears() time.Duration
- func TimeParseLocal(str string) (time.Time, error)
- func ToMapInterface(obj interface{}) map[interface{}]interface{}
- func TryLock(redisAddr, lockKey string, ex uint, retry int) error
- func USleep(us int64)
- func UnLock(redisAddr, lockKey string) error
- func UnixNanoToString(nano int64) string
- func UnixSecondToString(unix int64) string
- func WaitForTerminate()
- func WaitForTerminateChan(c chan struct{})
- func WaitForTerminateChanCb(c chan struct{}, cb func())
- func WalkDir(dirPath string, recursive bool) ([]string, error)
- func WalkDirDirs(dirPath string, recursive bool) ([]string, error)
- func WalkDirDirsWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
- func WalkDirFiles(dirPath string, recursive bool) ([]string, error)
- func WalkDirFilesWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
- func WalkDirWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
- type Dispatcher
- type ID
- func IDFromB64(s string) ID
- func IDFromString(s string) ID
- func ParseBase2(id string) (ID, error)
- func ParseBase32(b []byte) (ID, error)
- func ParseBase36(id string) (ID, error)
- func ParseBase58(b []byte) (ID, error)
- func ParseBase64(id string) (ID, error)
- func ParseBytes(id []byte) (ID, error)
- func ParseInt64(id int64) ID
- func ParseIntBytes(id [8]byte) ID
- func ParseString(id string) (ID, error)
- func (this ID) B64() string
- func (f ID) Base2() string
- func (f ID) Base32() string
- func (f ID) Base36() string
- func (f ID) Base58() string
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (this ID) IsValidProcessId() bool
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (this ID) ProcessId() ProcessId
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() time.Time
- func (f ID) TimeSecond() time.Time
- func (f ID) TimeUnix() int64
- func (f *ID) UnmarshalJSON(b []byte) error
- type Iterator
- type JSONSyntaxError
- type Job
- type OrderedPair
- type PipeLine
- type PipeWorker
- type ProcessId
- type Queue
- type RemoveMapCondition
- type RingBuffer
- func (this *RingBuffer[T]) Capacity() int
- func (this *RingBuffer[T]) Deq() T
- func (this *RingBuffer[T]) DeqN(count int) T
- func (this *RingBuffer[T]) Enq(element T) int
- func (this *RingBuffer[T]) IsEmpty() bool
- func (this *RingBuffer[T]) IsFull() bool
- func (this *RingBuffer[T]) Peek() T
- func (this *RingBuffer[T]) PeekN(count int) []T
- func (this RingBuffer[T]) Size() int
- type ScheduleTask
- type Set
- type Snowflake
- type TaskID
- type Timer
- func (t *Timer) GetPrevInterval() int64
- func (t *Timer) GetRunningTime() int64
- func (t *Timer) GetTimeOffset() int64
- func (t *Timer) GetTimeScale() float32
- func (t *Timer) GetUpdateTime() int64
- func (t *Timer) Now() int64
- func (t *Timer) Pause()
- func (t *Timer) Reset()
- func (t *Timer) Resume()
- func (t *Timer) Schedule(name string, interval int64, count int, task func(int64, int64), delay int64, ...)
- func (t *Timer) Start()
- func (t *Timer) Stop()
- func (t *Timer) Unschedule(task interface{})
- type TimerState
- type TimerType
- type WalkDirFunc
- type WorkerPool
Constants ¶
const RegExpCh = `[一-龥]`
Variables ¶
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1420070400000 // NodeBits holds the number of bits to use for Snowflake // Remember, you have a total 22 bits to share between Snowflake/Step NodeBits uint8 = 10 // StepBits holds the number of bits to use for Step // Remember, you have a total 22 bits to share between Snowflake/Step StepBits uint8 = 12 )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
var FlagUtil = &flagUtil{ items: map[string]*flagValue{}, }
var Time2028 = time.Date(2028, 1, 1, 0, 0, 0, 0, time.Local)
Functions ¶
func Binary2Byte ¶
func Binary2Short ¶
func CheckDuplicate ¶
func CheckDuplicate(slice interface{}) bool
func CheckDuplicateString ¶
func CheckTimeFormat ¶
func ConfDecode ¶
func ConfFormat ¶
func CreateFile ¶
func CurrentPath ¶ added in v0.2.9
func DigitalNum ¶
func DigitalToString ¶
func ExternalIP ¶
func FilterFileWithExt ¶
func FormatTimeToDayString ¶
func FormatTimeToISOString ¶ added in v0.1.24
func FormatTimeToMonthString ¶
func FormatTimeToString ¶
func FormatTimeToYearString ¶
func GetCurrentDirectory ¶ added in v0.1.24
func GetCurrentDirectory() string
func GetDateNoOffset ¶
func GetGoroutineID ¶
func GetGoroutineID() uint64
func GetLastWeekDay ¶ added in v0.2.30
func GetMonthDayByLastWeekDay ¶ added in v0.2.30
func GetMonthStartEnd ¶ added in v0.2.30
获取本月的起始时间
func GetNextMonthsStart ¶ added in v0.2.31
func GetNowDateWithOffset ¶
GetNowDateWithOffset 得到带重置时间的当天的YYYYMMHH
func GetParentDirectory ¶ added in v0.1.24
func GetPublicIp ¶ added in v0.2.21
func GetPublicIp() string
func GetTimeFromMs ¶
func GetWeekDay ¶ added in v0.2.30
获取这星期的星期几
func HasReflectTypeInSlice ¶
func IsFileExist ¶ added in v0.0.6
func IsFileModified ¶ added in v0.2.4
func IsFileWithExt ¶ added in v0.1.24
func IsProcessExist ¶ added in v0.1.25
func LoadRSAPrivateKeyPem ¶
func LoadRSAPrivateKeyPem(p string) (*rsa.PrivateKey, error)
func MilliSecondToString ¶
func PathExists ¶
func RemoveMapElement ¶
func RemoveMapElement[T1 comparable, T2 comparable](obj map[T1]T2, elem T2) map[T1]T2
func RemoveMapWithCondition ¶
func RemoveMapWithCondition[T1 comparable, T2 any](obj map[T1]T2, f func(key T1, elem T2) bool) map[T1]T2
func ReplaceTextParams ¶ added in v0.2.28
func Struct2Map ¶
func ToMapInterface ¶
func ToMapInterface(obj interface{}) map[interface{}]interface{}
func UnixNanoToString ¶
func UnixSecondToString ¶
func WaitForTerminate ¶
func WaitForTerminate()
func WaitForTerminateChan ¶
func WaitForTerminateChan(c chan struct{})
func WaitForTerminateChanCb ¶
func WaitForTerminateChanCb(c chan struct{}, cb func())
func WalkDirDirsWithFunc ¶
func WalkDirDirsWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
func WalkDirFilesWithFunc ¶
func WalkDirFilesWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
func WalkDirWithFunc ¶
func WalkDirWithFunc(dirPath string, walkFunc WalkDirFunc, recursive bool) ([]string, error)
Types ¶
type Dispatcher ¶
type Dispatcher interface { }
type ID ¶
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func IDFromString ¶
func ParseBase2 ¶
ParseBase2 converts a Base2 string into a snowflake ID
func ParseBase32 ¶
ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func ParseBase36 ¶
ParseBase36 converts a Base36 string into a snowflake ID
func ParseBase58 ¶
ParseBase58 parses a base58 []byte into a snowflake ID
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake ID
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶
ParseString converts a string into a snowflake ID
func (ID) Base32 ¶
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (ID) IntBytes ¶
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) IsValidProcessId ¶
func (ID) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake ID.
func (ID) Node ¶
Snowflake returns an int64 of the snowflake ID node number DEPRECATED: the below function will be removed in a future release.
func (ID) Step ¶
Step returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.
func (ID) TimeSecond ¶ added in v0.1.30
func (ID) TimeUnix ¶
Time returns an int64 unix timestamp in milliseconds of the snowflake ID time DEPRECATED: the below function will be removed in a future release.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type Iterator ¶
type Iterator struct { C <-chan interface{} // contains filtered or unexported fields }
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type OrderedPair ¶
type OrderedPair struct { First interface{} Second interface{} }
An OrderedPair represents a 2-tuple of values.
func (*OrderedPair) Equal ¶
func (pair *OrderedPair) Equal(other OrderedPair) bool
Equal says whether two 2-tuples contain the same values in the same order.
func (OrderedPair) String ¶
func (pair OrderedPair) String() string
String outputs a 2-tuple in the form "(A, B)".
type PipeWorker ¶
type PipeWorker interface { }
func CreatePipeWorker ¶
func CreatePipeWorker() *PipeWorker
type RemoveMapCondition ¶
type RemoveMapCondition func(key interface{}, elem interface{}) bool
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
func NewRingBuffer ¶
func NewRingBuffer[T any](capacity int) *RingBuffer[T]
func (*RingBuffer[T]) Capacity ¶
func (this *RingBuffer[T]) Capacity() int
func (*RingBuffer[T]) Deq ¶
func (this *RingBuffer[T]) Deq() T
func (*RingBuffer[T]) DeqN ¶
func (this *RingBuffer[T]) DeqN(count int) T
func (*RingBuffer[T]) Enq ¶
func (this *RingBuffer[T]) Enq(element T) int
func (*RingBuffer[T]) IsEmpty ¶
func (this *RingBuffer[T]) IsEmpty() bool
func (*RingBuffer[T]) IsFull ¶
func (this *RingBuffer[T]) IsFull() bool
func (*RingBuffer[T]) Peek ¶
func (this *RingBuffer[T]) Peek() T
func (*RingBuffer[T]) PeekN ¶
func (this *RingBuffer[T]) PeekN(count int) []T
func (RingBuffer[T]) Size ¶
func (this RingBuffer[T]) Size() int
type ScheduleTask ¶
type ScheduleTask struct {
// contains filtered or unexported fields
}
type Set ¶
type Set interface { Add(i interface{}) bool Cardinality() int Clear() Clone() Set Contains(i ...interface{}) bool Difference(other Set) Set Equal(other Set) bool Intersect(other Set) Set IsProperSubset(other Set) bool IsProperSuperset(other Set) bool IsSubset(other Set) bool IsSuperset(other Set) bool Each(func(interface{}) bool) Iter() <-chan interface{} Iterator() *Iterator Remove(i interface{}) String() string SymmetricDifference(other Set) Set Union(other Set) Set Pop() interface{} PowerSet() Set CartesianProduct(other Set) Set ToSlice() []interface{} }
func NewSetFromSlice ¶
func NewSetFromSlice(s []interface{}) Set
func NewSetWith ¶
func NewSetWith(elts ...interface{}) Set
func NewThreadUnsafeSet ¶
func NewThreadUnsafeSet() Set
func NewThreadUnsafeSetFromSlice ¶
func NewThreadUnsafeSetFromSlice(s []interface{}) Set
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
A Snowflake struct holds the basic information needed for a snowflake generator node
func NewSnowflake ¶
NewNode returns a new snowflake node that can be used to generate snowflake IDs
type Timer ¶
type Timer struct { OnUpdate func(dt int64, now int64) OnLateUpdate func(dt int64, now int64) OnStart func(now int64) OnStop func(now int64) OnPause func(now int64) OnResume func(now int64) OnDestroy func(now int64) // contains filtered or unexported fields }
func (*Timer) GetPrevInterval ¶
func (*Timer) GetRunningTime ¶
func (*Timer) GetTimeOffset ¶
func (*Timer) GetTimeScale ¶
func (*Timer) GetUpdateTime ¶
func (*Timer) Unschedule ¶
func (t *Timer) Unschedule(task interface{})
type TimerState ¶
type TimerState int
const ( TIMER_STOP TimerState = 0 TIMER_START TimerState = 1 TIMER_ONSTOP TimerState = 2 )