Versions in this module Expand all Collapse all v1 v1.6.0 Oct 18, 2021 Changes in this version + const Default + func AddSlashes(s string) string + func Date(timestamp int64, layout ...string) string + func Float64sUnique(a []float64) []float64 + func GenerateRSAKey(bitSize int, blockType PemBlockType) (privateKey, publicKey []byte, err error) + func HMAC(algo HashAlgo, s, key string) string + func HTTPDo(ctx context.Context, method, reqURL string, body io.Reader, ...) (*http.Response, error) + func HTTPGet(ctx context.Context, reqURL string, options ...HTTPOption) (*http.Response, error) + func HTTPPost(ctx context.Context, reqURL string, body []byte, options ...HTTPOption) (*http.Response, error) + func HTTPPostForm(ctx context.Context, reqURL string, data url.Values, options ...HTTPOption) (*http.Response, error) + func HTTPUpload(ctx context.Context, reqURL string, form UploadForm, options ...HTTPOption) (*http.Response, error) + func Hash(algo HashAlgo, s string) string + func IP2Long(ip string) uint32 + func InArray(needle interface{}, haystack []interface{}) bool + func InFloat64s(needle float64, haystack []float64) bool + func InInt64s(needle int64, haystack []int64) bool + func InInts(needle int, haystack []int) bool + func InStrings(needle string, haystack []string) bool + func Init(options ...InitOption) + func Int64sUnique(a []int64) []int64 + func IntsUnique(a []int) []int + func LoadEnv(options ...EnvOption) error + func Logger(name ...string) *zap.Logger + func Long2IP(ip uint32) string + func MD5(s string) string + func Mongo(name ...string) *mongo.Client + func MyTimeEncoder(t time.Time, e zapcore.PrimitiveArrayEncoder) + func NSQDeferredPublish(topic string, msg NSQMessage, duration time.Duration) error + func NSQPublish(topic string, msg NSQMessage) error + func NewECBDecrypter(b cipher.Block) cipher.BlockMode + func NewECBEncrypter(b cipher.Block) cipher.BlockMode + func NextAttemptDuration(attempts uint16) time.Duration + func PKCS5Padding(cipherText []byte, blockSize int) []byte + func PKCS5Unpadding(plainText []byte, blockSize int) []byte + func QuoteMeta(s string) string + func RSADecrypt(cipherText, privateKey []byte) ([]byte, error) + func RSADecryptOEAP(cipherText, privateKey []byte) ([]byte, error) + func RSAEncrypt(plainText, publicKey []byte) ([]byte, error) + func RSAEncryptOEAP(plainText, publicKey []byte) ([]byte, error) + func RSAPemToSSH(pemPubKey []byte) (sshRSA []byte, fingerprint string, err error) + func RSASignWithSha256(data, privateKey []byte) ([]byte, error) + func RSAVerifyWithSha256(data, signature, publicKey []byte) error + func SHA1(s string) string + func SearchInt64s(a []int64, x int64) int + func SortInt64s(a []int64) + func StrToTime(datetime string, layout ...string) int64 + func StringsUnique(a []string) []string + func StripSlashes(s string) string + func VersionCompare(rangeVer, curVer string) (bool, error) + func WeekAround(t time.Time) (monday, sunday string) + func ZeroPadding(cipherText []byte, blockSize int) []byte + func ZeroUnPadding(plainText []byte) []byte + type AESCrypto interface + Decrypt func(cipherText []byte) ([]byte, error) + Encrypt func(plainText []byte) ([]byte, error) + func NewCBCCrypto(key, iv []byte, mode PaddingMode) AESCrypto + func NewCFBCrypto(key, iv []byte) AESCrypto + func NewCTRCrypto(key, iv []byte) AESCrypto + func NewECBCrypto(key []byte, mode PaddingMode) AESCrypto + func NewGCMCrypto(key, nonce []byte) AESCrypto + func NewOFBCrypto(key, iv []byte) AESCrypto + type CDATA string + func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error + type EnvEventFunc func(event fsnotify.Event) + type EnvOption func(e *environment) + func WithEnvFile(filename string) EnvOption + func WithEnvWatcher(fn ...EnvEventFunc) EnvOption + type GRPCConn struct + func (gc *GRPCConn) Close() + type GRPCDialFunc func() (*grpc.ClientConn, error) + type GRPCPool interface + Get func(ctx context.Context) (*GRPCConn, error) + Put func(gc *GRPCConn) + func NewGRPCPool(dial GRPCDialFunc, options ...PoolOption) GRPCPool + type HTTPClient interface + Do func(ctx context.Context, method, reqURL string, body io.Reader, ...) (*http.Response, error) + Upload func(ctx context.Context, reqURL string, form UploadForm, options ...HTTPOption) (*http.Response, error) + func NewHTTPClient(client *http.Client) HTTPClient + type HTTPOption func(s *httpSetting) + func WithHTTPClose() HTTPOption + func WithHTTPCookies(cookies ...*http.Cookie) HTTPOption + func WithHTTPHeader(key, value string) HTTPOption + type HashAlgo string + const AlgoMD5 + const AlgoSha1 + const AlgoSha224 + const AlgoSha256 + const AlgoSha384 + const AlgoSha512 + type InitOption func(s *initSetting) + func WithLogger(name, logfile string, options ...LoggerOption) InitOption + func WithMongo(name string, dsn string) InitOption + func WithNSQ(nsqd string, lookupd []string, options ...NSQOption) InitOption + func WithRedis(name, address string, options ...RedisOption) InitOption + type Int64Slice []int64 + func (p Int64Slice) Len() int + func (p Int64Slice) Less(i, j int) bool + func (p Int64Slice) Swap(i, j int) + type LoggerOption func(s *loggerSetting) + func WithLogCompress() LoggerOption + func WithLogMaxAge(n int) LoggerOption + func WithLogMaxBackups(n int) LoggerOption + func WithLogMaxSize(n int) LoggerOption + func WithLogStdErr() LoggerOption + type NSQConsumer interface + AttemptCount func() uint16 + Channel func() string + Topic func() string + type NSQLogger struct + func (l *NSQLogger) Output(calldepth int, s string) error + type NSQMessage interface + Bytes func() ([]byte, error) + Do func() error + type NSQOption func(s *nsqSetting) + func WithLookupdPollInterval(t time.Duration) NSQOption + func WithMaxInFlight(n int) NSQOption + func WithNSQConsumer(consumer NSQConsumer) NSQOption + func WithRDYRedistributeInterval(t time.Duration) NSQOption + type PaddingMode string + const PKCS5 + const PKCS7 + const ZERO + type PemBlockType string + const RSAPKCS1 + const RSAPKCS8 + type PoolOption func(s *poolSetting) + func WithPoolIdleTimeout(duration time.Duration) PoolOption + func WithPoolLimit(limit int) PoolOption + func WithPoolPrefill(prefill int) PoolOption + func WithPoolSize(size int) PoolOption + type RedisConn struct + func (rc *RedisConn) Close() + type RedisOption func(s *redisSetting) + func WithRedisConnTimeout(t time.Duration) RedisOption + func WithRedisDatabase(db int) RedisOption + func WithRedisPool(options ...PoolOption) RedisOption + func WithRedisReadTimeout(t time.Duration) RedisOption + func WithRedisWriteTimeout(t time.Duration) RedisOption + type RedisPool interface + Get func(ctx context.Context) (*RedisConn, error) + Put func(rc *RedisConn) + func Redis(name ...string) RedisPool + type SSHKey struct + Fingerprint string + IDRSA []byte + IDRSAPub []byte + func GenerateSSHKey() (*SSHKey, error) + type UploadField func(f *uploadform) + func WithFileField(fieldname, filename string, body []byte) UploadField + func WithFormField(fieldname, fieldvalue string) UploadField + type UploadForm interface + Write func(w *multipart.Writer) error + func NewUploadForm(fields ...UploadField) UploadForm + type Validator struct + func NewValidator() *Validator + func (v *Validator) Engine() interface{} + func (v *Validator) ValidateStruct(obj interface{}) error + type X map[string]interface