Documentation ¶
Index ¶
- Constants
- Variables
- func AddressCanListen(addr string) bool
- func AnyType[T any]() reflect.Type
- func AnyValuePointer[T any](v T) *T
- func BeanHasFieldCallback(bean interface{}, fieldName string, calls ...func(v reflect.Value)) bool
- func CeilFloat64(val float64, precision int) float64
- func CheckPassword(p, c string) error
- func CloseWriters()
- func ConcurrentRun(fn func(), num int)
- func Contains[T comparable](a []T, x T) bool
- func DecryptPassword(p string) (s string, err error)
- func EncryptPassword(p string) string
- func FloorFloat64(val float64, precision int) float64
- func FuncName(fn interface{}) string
- func FuncNameFull(fn interface{}) string
- func GJson(data []byte) gjson.Result
- func GenNanoid(n int) string
- func GenNanoidNums(ns ...int) string
- func GenUUID16(sep string, uuidVs ...uuid.UUID) string
- func GenUUID16unix(sep string, uuidVs ...uuid.UUID) string
- func GetLogWriter(logName string) io.WriteCloser
- func InjectPopulate(values ...interface{})
- func JSONDump(val interface{}, args ...interface{}) string
- func JSONEncodeDisableEscapeHTML(val interface{}) (bytesResult []byte, err error)
- func JSONExchange(dst interface{}, src interface{}) error
- func JSONMarshalToBase64(val interface{}) ([]byte, error)
- func JSONUnmarshalFromBase64(data []byte, val interface{}) error
- func JsMarshal(val interface{}) (bts []byte)
- func JsMarshalHex(val interface{}) (dst []byte, err error)
- func JsMarshalIndent(val interface{}) (bts []byte)
- func JsUnmarshalHex(data []byte, val interface{}) (err error)
- func LoadAntSPool() *ants.Pool
- func LoadSingle[T any](newFunc func() T) T
- func LoadSingleInstance[T any](key string, newFunc func() T) T
- func LocalUploadPath() string
- func MD5(s string) string
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalToString(v interface{}, args ...interface{}) (string, error)
- func MergeBean(target, source interface{}) error
- func MergeMap(target, source Map)
- func MustParsePreFloat64(value float64, pre int) float64
- func NewGroupError(group []error) error
- func NewValue(bean interface{}) (val interface{})
- func ObjectTagInstances(obj interface{}, tagName string) []interface{}
- func RandString(n int) string
- func ReflectIndirect(v interface{}) reflect.Value
- func ReflectValue(bean interface{}, fn func(v reflect.Value))
- func ReflectZeroFields(v interface{}, fields []string)
- func RemoveUploadFile(filePathName string)
- func RetryDo(fn func() error, intervalSecond int64) error
- func RetryDoTimes(times, intervalSecond int64, fn func() error) error
- func RoundFloat64(val float64, precision int) float64
- func SetInnerCrypto(k string)
- func SetJson(data []byte, path string, val interface{}) []byte
- func SetTimeZone() error
- func ShortUUID(uuidVs ...uuid.UUID) string
- func SlicePointerValue(bean interface{}) reflect.Value
- func TextTemplateMustParse(text string, data interface{}) (result string)
- func Ticker(d time.Duration, fn func())
- func TimeExcWrap(fn func()) time.Duration
- func TimeNow() time.Time
- func TodayDate() string
- func TrimByteSliceSpace(data []byte) []byte
- func TrimKey(k string) string
- func UUID16md5hex(uuidVs ...uuid.UUID) string
- func UUIDString(uuidVs ...uuid.UUID) string
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalFromString(data string, v interface{}) error
- func Upload(r *http.Request) (filePathName string, err error)
- func ValueIndirect(val reflect.Value) reflect.Value
- func WaitSignal()
- func WrapSignal(fn func())
- type CloseableChannel
- func (c *CloseableChannel[T]) Channel() <-chan T
- func (c *CloseableChannel[T]) Close()
- func (c *CloseableChannel[T]) Dequeue() (val T, ok bool)
- func (c *CloseableChannel[T]) Enqueue(value T)
- func (c *CloseableChannel[T]) IsClosed() bool
- func (c *CloseableChannel[T]) LockWrapFunc(fn func())
- func (c *CloseableChannel[T]) RLockWrapFunc(fn func())
- func (c *CloseableChannel[T]) Send(val T)
- func (c *CloseableChannel[T]) SendWithDefaultTimeout(val T)
- func (c *CloseableChannel[T]) SendWithTimeout(val T, timeout time.Duration)
- type CloseableType
- type Cron
- type Crypto
- type Decoder
- type Encoder
- type GQueue
- type GQueueHandler
- type GQueueOption
- type ItfLogger
- type JSONTime
- func (p *JSONTime) Add(d time.Duration) *JSONTime
- func (p *JSONTime) Convert2Time() time.Time
- func (p *JSONTime) Date() *JSONTime
- func (p *JSONTime) FromDB(data []byte) error
- func (p *JSONTime) GobDecode(data []byte) error
- func (p *JSONTime) GobEncode() ([]byte, error)
- func (p *JSONTime) MarshalJSON() ([]byte, error)
- func (p *JSONTime) Scan(v interface{}) error
- func (p *JSONTime) SetByTime(timeVal time.Time)
- func (p *JSONTime) String() string
- func (p *JSONTime) StringFormat(layout string) string
- func (p *JSONTime) Time() time.Time
- func (p *JSONTime) ToDB() (b []byte, err error)
- func (p *JSONTime) UnmarshalJSON(data []byte) error
- func (p *JSONTime) Value() (driver.Value, error)
- type Map
- type QueueTask
- type QueueTaskOpt
- type RawMessage
- type Slice
- type Validator
- func (v *Validator) Constructor()
- func (v *Validator) Engine() interface{}
- func (v *Validator) New() *Validator
- func (v *Validator) TranslateZh(es error) (err error)
- func (v *Validator) Valid() *validator.Validate
- func (v *Validator) ValidAndTranslateZh(s interface{}) (err error)
- func (v *Validator) ValidVarWithTransZh(val interface{}, tag string) (err error)
- func (v *Validator) ValidateStruct(obj interface{}) error
Constants ¶
const ( //TimeZone ... TimeZone = "Asia/Shanghai" //Custom ... Custom = "2006-01-02 15:04:05" //DateLayout ... DateLayout = "2006-01-02" )
const ( B = 1 << (10 * iota) KB MB GB TB PB EB )
Byte unit helpers.
const (
Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)
const PathUpload = "upload"
Variables ¶
var ( AppName = "glib" CompileMod string Version string BuildTime string GoVersion string GitBranch string GitHash string )
var ( ErrorFileIsNotImage = errors.New("文件类型错误") ErrorFileIsTooLarge = errors.New("文件不能超过2MB") )
var ErrInvalidType = errors.New("invalid type")
var ErrPassword = errors.New("密码错误")
var RootDir = func() string { ec, _ := os.Executable() return filepath.Dir(ec) }
var TimeNowFunc = time.Now
TimeNowFunc ...
var ValidatorInc = new(Validator).New()
Functions ¶
func AddressCanListen ¶
func AnyValuePointer ¶
func AnyValuePointer[T any](v T) *T
func BeanHasFieldCallback ¶
BeanHasFieldCallback ... 判断是否存在字段 并回调
func CheckPassword ¶
CheckPassword ...c cipher_password p plaintext
func CloseWriters ¶
func CloseWriters()
func ConcurrentRun ¶
func ConcurrentRun(fn func(), num int)
func Contains ¶
func Contains[T comparable](a []T, x T) bool
func FloorFloat64 ¶
FloorFloat64 按小数位截取float 最小值
func FuncNameFull ¶
func FuncNameFull(fn interface{}) string
func GenNanoidNums ¶ added in v1.0.0
func GetLogWriter ¶
func GetLogWriter(logName string) io.WriteCloser
func JSONEncodeDisableEscapeHTML ¶ added in v1.0.0
func JSONExchange ¶
func JSONExchange(dst interface{}, src interface{}) error
JSONExchange ...使用json copy对象
func JSONMarshalToBase64 ¶
JSONMarshalToBase64 ...
func JSONUnmarshalFromBase64 ¶
JSONUnmarshalFromBase64 ...
func JsMarshalHex ¶
func JsUnmarshalHex ¶
func LoadAntSPool ¶ added in v1.0.0
func LoadAntSPool() *ants.Pool
func LoadSingle ¶
func LoadSingle[T any](newFunc func() T) T
func LoadSingleInstance ¶
LoadSingleInstance load the single instance
func LocalUploadPath ¶
func LocalUploadPath() string
func MarshalIndent ¶
func MarshalToString ¶
MarshalToString ...
func MergeBean ¶ added in v0.0.6
func MergeBean(target, source interface{}) error
MergeBean ...if source's field is not empty, then set target's field to source's field target and source must be pointer if source's field is empty, then target's field will not be changed
func MustParsePreFloat64 ¶
MustParsePreFloat64 按小数位截取float
func NewGroupError ¶
func ObjectTagInstances ¶
func ObjectTagInstances(obj interface{}, tagName string) []interface{}
ObjectTagInstances ... *
- @Description:根据标签获取字段实例集合
- @param obj
- @param tagName
- @return []interface{}
func RandString ¶
func ReflectValue ¶
ReflectValue ...回调函数
func ReflectZeroFields ¶
func ReflectZeroFields(v interface{}, fields []string)
ReflectZeroFields 将多个字段设置为零值
func RemoveUploadFile ¶
func RemoveUploadFile(filePathName string)
func RetryDoTimes ¶
RetryDoTimes ...
func RoundFloat64 ¶
RoundFloat64 按小数位截取float 四舍五入
func SlicePointerValue ¶
SlicePointerValue ...构建类型切片
func TextTemplateMustParse ¶
TextTemplateMustParse ...
func TrimByteSliceSpace ¶ added in v1.0.0
func UUID16md5hex ¶
func UnmarshalFromString ¶
UnmarshalFromString ...
func WaitSignal ¶ added in v1.0.0
func WaitSignal()
func WrapSignal ¶ added in v1.0.0
func WrapSignal(fn func())
Types ¶
type CloseableChannel ¶
type CloseableChannel[T any] struct { // contains filtered or unexported fields }
func NewCloseable ¶
func NewCloseable[T any](ch chan T) *CloseableChannel[T]
func (*CloseableChannel[T]) Channel ¶
func (c *CloseableChannel[T]) Channel() <-chan T
Channel returns the channel of the CloseableChannel.
func (*CloseableChannel[T]) Close ¶
func (c *CloseableChannel[T]) Close()
func (*CloseableChannel[T]) Dequeue ¶
func (c *CloseableChannel[T]) Dequeue() (val T, ok bool)
Dequeue removes a value from the front of the queue
func (*CloseableChannel[T]) Enqueue ¶
func (c *CloseableChannel[T]) Enqueue(value T)
Enqueue adds a value to the end of the queue
func (*CloseableChannel[T]) IsClosed ¶
func (c *CloseableChannel[T]) IsClosed() bool
func (*CloseableChannel[T]) LockWrapFunc ¶
func (c *CloseableChannel[T]) LockWrapFunc(fn func())
func (*CloseableChannel[T]) RLockWrapFunc ¶
func (c *CloseableChannel[T]) RLockWrapFunc(fn func())
func (*CloseableChannel[T]) Send ¶
func (c *CloseableChannel[T]) Send(val T)
func (*CloseableChannel[T]) SendWithDefaultTimeout ¶
func (c *CloseableChannel[T]) SendWithDefaultTimeout(val T)
func (*CloseableChannel[T]) SendWithTimeout ¶
func (c *CloseableChannel[T]) SendWithTimeout(val T, timeout time.Duration)
SendWithTimeout send val to the channel with timeout
type CloseableType ¶
type CloseableType interface { IsClosed() bool Close() Send(val interface{}) Channel() <-chan interface{} }
type Crypto ¶
type Crypto struct {
// contains filtered or unexported fields
}
Crypto ...
func (*Crypto) DecryptCBC ¶
DecryptCBC ...
type GQueue ¶
type GQueue struct {
// contains filtered or unexported fields
}
func NewGQueue ¶
func NewGQueue(opt GQueueOption) *GQueue
func (*GQueue) Register ¶
func (g *GQueue) Register(task string, handler GQueueHandler)
Register register task handler
type GQueueHandler ¶
type GQueueOption ¶
type ItfLogger ¶ added in v0.0.2
type ItfLogger interface { Close() error SetOutput(writer io.Writer) Writer() io.Writer Print(i ...interface{}) Printf(s string, i ...interface{}) Println(i ...interface{}) Fatal(i ...interface{}) Fatalf(s string, i ...interface{}) Fatalln(i ...interface{}) Panic(i ...interface{}) Panicf(s string, i ...interface{}) Panicln(i ...interface{}) Debugf(s string, i ...interface{}) Infof(s string, i ...interface{}) Warnf(s string, i ...interface{}) Errorf(s string, i ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) }
type JSONTime ¶
JSONTime ...
func NewJSONTimeOfTime ¶
NewJSONTimeOfTime 时间转换为JSONTime
func (*JSONTime) StringFormat ¶
StringFormat 转换为固定格式字符串
func (*JSONTime) UnmarshalJSON ¶
UnmarshalJSON ...
type Map ¶
type Map map[string]interface{}
func StructToMap ¶ added in v1.0.0
func StructToMap(v interface{}) Map
StructToMap ...alias of Bean2Map
type QueueTask ¶
type QueueTask struct { Name string `json:"name,omitempty"` Data []byte `json:"data,omitempty"` Retried int `json:"retried,omitempty"` Group int `json:"group,omitempty"` // contains filtered or unexported fields }
func NewQueueTask ¶
func NewQueueTask(name string, data []byte, opt ...QueueTaskOpt) QueueTask
type QueueTaskOpt ¶
type QueueTaskOpt func(task *QueueTask)
func WithQueueTaskGroup ¶
func WithQueueTaskGroup(group int) QueueTaskOpt
func WithQueueTaskMaxRetry ¶ added in v0.0.2
func WithQueueTaskMaxRetry(maxRetry int) QueueTaskOpt
func WithQueueTaskRetryDelayFunc ¶ added in v0.0.2
func WithQueueTaskRetryDelayFunc(retryDelayFunc func(retried int) time.Duration) QueueTaskOpt
func WithQueueTaskRunAt ¶ added in v0.0.2
func WithQueueTaskRunAt(runAt time.Time) QueueTaskOpt
type RawMessage ¶
type RawMessage = json.RawMessage
type Slice ¶ added in v1.0.0
type Slice[T any] []T
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator ...
func (*Validator) TranslateZh ¶
TranslateZh ...
func (*Validator) ValidAndTranslateZh ¶
ValidAndTranslateZh ...
func (*Validator) ValidVarWithTransZh ¶
ValidVarWithTransZh ...