Documentation ¶
Index ¶
- Constants
- Variables
- func All(pred Pred_t, items ...interface{}) (bool, interface{})
- func Any(pred Pred_t, items ...interface{}) (bool, interface{})
- func ArgsStringToArray(s string) []string
- func CamelSplit(str string, sep string) string
- func CamelSplitTokens(str string) []string
- func Capitalize(str string) string
- func ComposeURL(paths ...string) string
- func ConvertError(obj interface{}, toType string) error
- func DecodeMeta(str string) string
- func DescryptAESBase64(key, secret string) (string, error)
- func DescryptAESBase64Url(key, secret string) (string, error)
- func Distinct(list []string) []string
- func DistinctJoin(list []string, separator string) string
- func DumpAllGoroutineStack(w io.Writer)
- func EncryptAESBase64(key, msg string) (string, error)
- func EncryptAESBase64Url(key, msg string) (string, error)
- func FindWords(str []byte, offset int) []string
- func FloatRound(num float64, precision int) float64
- func GenRequestId(bytes int) string
- func GetAddrPort(addrPort string) (string, int)
- func GetBytes(sizeStr string) (int64, error)
- func GetOutboundIP() net.IP
- func GetSize(sizeStr, defaultSize string, base int64) (size int64, err error)
- func GetSizeBytes(sizeStr, defaultSize string) (int64, error)
- func GetSizeGB(sizeStr, defaultSize string) (int64, error)
- func GetSizeKB(sizeStr, defaultSize string) (int64, error)
- func GetSizeMB(sizeStr, defaultSize string) (int64, error)
- func GroupBy(items interface{}, ks selectFunc) (map[string][]interface{}, error)
- func HasPrefix(s string, prefix string) bool
- func HasSuffix(s string, suffix string) bool
- func InArray(v interface{}, in interface{}) (ok bool, i int)
- func InArray2[...](val T, array []T) (ok bool, i int)
- func InStringArray(val string, array []string) (ok bool, i int)
- func Ip2Int(ipString string) uint32
- func IpRangeCount(ipStart, ipEnd string) int
- func IsAscii(str string) bool
- func IsExitAddress(ip string) bool
- func IsHostLocal(ip uint32) bool
- func IsInArray[...](val T, array []T) bool
- func IsInStringArray(val string, array []string) bool
- func IsLinkLocal(ip uint32) bool
- func IsLocalStorage(storageType string) bool
- func IsMatch(s string, pattern string) bool
- func IsMatchCompactMacAddr(s string) bool
- func IsMatchFloat(s string) bool
- func IsMatchIP4(s string) bool
- func IsMatchIP6(s string) bool
- func IsMatchInteger(s string) bool
- func IsMatchMacAddr(s string) bool
- func IsMatchSize(s string) bool
- func IsMatchUUID(s string) bool
- func IsPrivate(ip uint32) bool
- func Kebab2Camel(kebab string, sep string) string
- func Max(a int64, b int64) int64
- func Min(a int64, b int64) int64
- func RsaDecryptBase64(privateKey []byte, secret string) (string, error)
- func RsaEncryptBase64(publicKey []byte, origData string) (string, error)
- func RsaSign(privateKey []byte, message string) (string, error)
- func RsaUnsign(publicKey []byte, message, sign string) error
- func SavePid(pidfile string) error
- func SelectDistinct(items []interface{}, ks selectFunc) ([]string, error)
- func SplitCSV(csv string) []string
- func SubDict(dict map[string][]interface{}, keys ...string) (map[string][]interface{}, error)
- func TagMap(tag reflect.StructTag) map[string]string
- func TagPop(m map[string]string, key string) (map[string]string, string, bool)
- func ToBool(str string) bool
- func ToDict(objs interface{}, ks selectFunc) (map[string]interface{}, error)
- func ToDuration(i interface{}) time.Duration
- func ToDurationE(i interface{}) (d time.Duration, err error)
- func ToFloat64(i interface{}) float64
- func ToFloat64E(i interface{}) (float64, error)
- func ToInt64(i interface{}) int64
- func ToInt64E(i interface{}) (int64, error)
- func ToStatDict2(items []StatItem2) (map[string]interface{}, error)
- func ToStatDict3(items []StatItem3) (map[string]map[string]interface{}, error)
- func TransSQLAchemyURL(pySQLSrc string) (dialect, ret string, err error)
- func Truncate(s string, length int) string
- func TruncateString(v interface{}, maxLen int) string
- func Unquote(str string) string
- func WaitTimeOut(wg *WaitGroupWrapper, timeout time.Duration) bool
- type FibonacciRetrier
- type FibonacciRetrierError
- type FibonacciRetrierErrorType
- type FibonacciRetryFunc
- type Pred_t
- type StatItem2
- type StatItem3
- type WaitGroupWrapper
Constants ¶
const (
EMPTYSTR = " \t\n\r"
)
Variables ¶
var ( PrivateIP1Start = Ip2Int("10.0.0.0") PrivateIP1End = Ip2Int("10.255.255.255") PrivateIP2Start = Ip2Int("172.16.0.0") PrivateIP2End = Ip2Int("172.31.255.255") PrivateIP3Start = Ip2Int("192.168.0.0") PrivateIP3End = Ip2Int("192.168.255.255") HostLocalIPStart = Ip2Int("127.0.0.0") HostLocalIPEnd = Ip2Int("127.255.255.255") LinkLocalIPStart = Ip2Int("169.254.0.0") LinkLocalIPEnd = Ip2Int("169.254.255.255") )
var TRUE_STRS = []string{"1", "true", "on", "yes"}
Functions ¶
func ArgsStringToArray ¶
func CamelSplit ¶
func CamelSplitTokens ¶
func Capitalize ¶
func ComposeURL ¶
func ConvertError ¶
func DecodeMeta ¶
func DescryptAESBase64 ¶
func DescryptAESBase64Url ¶
func DistinctJoin ¶
func DumpAllGoroutineStack ¶
func EncryptAESBase64 ¶
func EncryptAESBase64Url ¶
func FloatRound ¶
func GenRequestId ¶
func GetAddrPort ¶
func GetOutboundIP ¶
func GetSize ¶
GetSize parse size string to int defaultSize be used when sizeStr not end with defaultSize sizeStr: 1024, 1M, 1m, 1K etc. defaultSize: g, m, k, b etc. base: base multiple unit, 1024
func GetSizeBytes ¶
func IpRangeCount ¶
func IsExitAddress ¶
func IsHostLocal ¶
func IsInStringArray ¶
func IsLinkLocal ¶
func IsLocalStorage ¶
func IsMatchCompactMacAddr ¶
func IsMatchFloat ¶
func IsMatchIP4 ¶
func IsMatchIP6 ¶
func IsMatchInteger ¶
func IsMatchMacAddr ¶
func IsMatchSize ¶
func IsMatchUUID ¶
func Kebab2Camel ¶
func RsaDecryptBase64 ¶
Base64封装的 RSA 密文解密
func RsaEncryptBase64 ¶
Base64封装的 RSA 密文解密
func SelectDistinct ¶
func ToDuration ¶
func ToDurationE ¶
func ToFloat64 ¶
func ToFloat64(i interface{}) float64
ToFloat64 casts an interface to a float64 type.
func ToFloat64E ¶
ToFloat64E casts an interface to a float64 type.
func ToStatDict2 ¶
func TransSQLAchemyURL ¶
func TruncateString ¶
func WaitTimeOut ¶
func WaitTimeOut(wg *WaitGroupWrapper, timeout time.Duration) bool
Types ¶
type FibonacciRetrier ¶
type FibonacciRetrier struct { // T0 is the 1st item in fibonacci series T0 time.Duration // T1 is the 2nd item in fibonacci series T1 time.Duration MaxTries int MaxElapse time.Duration RetryFunc FibonacciRetryFunc // contains filtered or unexported fields }
FibonacciRetrier calls RetryFunc until it returns done, or waits in fibonacci way until MaxTries, MaxElapse are exceeded whichever happens first
func NewFibonacciRetrierMaxElapse ¶
func NewFibonacciRetrierMaxElapse(maxElapse time.Duration, retryFunc FibonacciRetryFunc) *FibonacciRetrier
NewFibonacciRetrierMaxTries returnes a retrier that tries for at most maxElapse duration with the first 2 items being 1 second
func NewFibonacciRetrierMaxTries ¶
func NewFibonacciRetrierMaxTries(maxTries int, retryFunc FibonacciRetryFunc) *FibonacciRetrier
NewFibonacciRetrierMaxTries returnes a retrier that tries at most maxTries times with the first 2 items being 1 second
func (*FibonacciRetrier) Elapsed ¶
func (fibr *FibonacciRetrier) Elapsed() time.Duration
Elapsed returns the duration the retrier has run
func (*FibonacciRetrier) Start ¶
func (fibr *FibonacciRetrier) Start(ctx context.Context) (done bool, err error)
Start initiates the call and wait sequence
If RetryFunc returns with done being true. err will also be what RetryFunc returns
Otherwise Start will return with done being false and err of type FibonacciRetrierError with last err returned by RetryFunc wrapped in, or ctx.Err() if it's done
func (*FibonacciRetrier) Tried ¶
func (fibr *FibonacciRetrier) Tried() int
Tries returns number of times RetryFunc has been called, excluding the current executing one
type FibonacciRetrierError ¶
type FibonacciRetrierError struct { Type FibonacciRetrierErrorType // Fibr is a copy of the original retrier. Fibr FibonacciRetrier // Err is the original error returned by retry func. It can be nil. Err error }
FibonacciRetrierError is the type of error retrier returns when MaxTries or MaxElapse are exceeded.
func (FibonacciRetrierError) Error ¶
func (err FibonacciRetrierError) Error() string
type FibonacciRetrierErrorType ¶
type FibonacciRetrierErrorType int
FibonacciRetrierErrorType is the error type that could be returned by retrier
const ( FibonacciRetrierErrorMaxTriesExceeded FibonacciRetrierErrorType = iota FibonacciRetrierErrorMaxElapseExceeded )
type FibonacciRetryFunc ¶
type FibonacciRetryFunc func(retrier FibonacciRetrier) (done bool, err error)
FibonacciRetryFunc is the type of func retrier calls.
type WaitGroupWrapper ¶
func (*WaitGroupWrapper) Wrap ¶
func (w *WaitGroupWrapper) Wrap(cb func())