Versions in this module Expand all Collapse all v1 v1.0.4 Feb 20, 2025 Changes in this version + func BindProto(r *http.Request, msg proto.Message) error v1.0.3 Feb 17, 2025 Changes in this version + const ContentMultipartForm + func BindForm(r *http.Request, obj any) error + func BindJSON(r *http.Request, obj any) error v1.0.2 Feb 13, 2025 Changes in this version + type Mutex interface + Lock func(ctx context.Context) (bool, error) + TryLock func(ctx context.Context, attempts int, delay time.Duration) (bool, error) + UnLock func(ctx context.Context) error + func RedLock(cli *redis.Client, key string, ttl time.Duration) Mutex v1.0.1 Feb 11, 2025 v1.0.0 Feb 11, 2025 Changes in this version + const B + const ContentForm + const ContentFormMultipart + const ContentJSON + const ContentStream + const ContentText + const ContentXML + const GiB + const HeaderAccept + const HeaderAuthorization + const HeaderContentType + const KiB + const MaxFormMemory + const MediaThumbnailWidth + const MiB + const TiB + var ErrSQLBatchDataType = errors.New("invaild data type, expects: []struct, []*struct, []yiigo.X") + var ErrSQLDataType = errors.New("invaild data type, expects: struct, *struct, yiigo.X") + var GMT8 = time.FixedZone("CST", 8 * 3600) + var RestyClient = resty.NewWithClient(NewHttpClient()) + func AddSlashes(s string) string + func ContentType(h http.Header) string + func CreateFile(filename string) (*os.File, error) + func DebugLogger(options ...zap.Option) *zap.Logger + func ExcelColumnIndex(name string) int + func IP2Long(ip string) uint32 + func ImageCrop(w io.Writer, filename string, rect *Rect, options ...imaging.EncodeOption) error + func ImageCropFromReader(w io.Writer, r io.Reader, format imaging.Format, rect *Rect, ...) error + func ImageLabel(w io.Writer, filename string, rects []*Rect, options ...imaging.EncodeOption) error + func ImageLabelFromReader(w io.Writer, r io.Reader, format imaging.Format, rects []*Rect, ...) error + func ImageThumbnail(w io.Writer, filename string, rect *Rect, options ...imaging.EncodeOption) error + func ImageThumbnailFromReader(w io.Writer, r io.Reader, format imaging.Format, rect *Rect, ...) error + func IsUniqueDuplicateError(err error) bool + func Long2IP(ip uint32) string + func MapForm(ptr any, form map[string][]string) error + func MapFormByTag(ptr any, form map[string][]string, tag string) error + func MapQuery(ptr any, m map[string][]string) error + func MappingByPtr(ptr any, setter setter, tag string) error + func MarshalNoEscapeHTML(v any) ([]byte, error) + func MyTimeEncoder(t time.Time, e zapcore.PrimitiveArrayEncoder) + func NewDB(cfg *DBConfig) (*sql.DB, error) + func NewDBx(cfg *DBConfig) (*sqlx.DB, error) + func NewHttpClient() *http.Client + func NewLogger(cfg *LogConfig) *zap.Logger + func Nonce(size uint8) string + func OpenFile(filename string) (*os.File, error) + func QuoteMeta(s string) string + func Retry(ctx context.Context, fn func(ctx context.Context) error, attempts int, ...) (err error) + func SliceChunk[T ~[]E, E any](list T, size int) []T + func SliceDiff[T ~[]E, E comparable](list1 T, list2 T) (ret1 T, ret2 T) + func SliceIn[T ~[]E, E comparable](list T, elem E) bool + func SliceIntersect[T ~[]E, E comparable](list1 T, list2 T) T + func SlicePinTopF[T ~[]E, E any](list T, fn func(v E) bool) + func SlicePinTop[T ~[]E, E any](list T, index int) + func SliceRand[T ~[]E, E any](list T, n int) T + func SliceUnion[T ~[]E, E comparable](lists ...T) T + func SliceUniq[T ~[]E, E comparable](list T) T + func SliceWithout[T ~[]E, E comparable](list T, exclude ...E) T + func StrToTime(layout, datetime string, loc *time.Location) time.Time + func StripSlashes(s string) string + func TimeToStr(layout string, timestamp int64, loc *time.Location) string + func Transaction(ctx context.Context, db *sqlx.DB, ...) (err error) + func VersionCompare(rangeVer, curVer string) (bool, error) + func WeekAround(layout string, now time.Time) (monday, sunday string) + type DBConfig struct + ConnMaxIdleTime time.Duration + ConnMaxLifetime time.Duration + DSN string + Driver string + MaxIdleConns int + MaxOpenConns int + type DistributedMutex interface + Lock func(ctx context.Context) (bool, error) + TryLock func(ctx context.Context, attempts int, delay time.Duration) (bool, error) + UnLock func(ctx context.Context) error + func RedisMutex(cli *redis.Client, key string, ttl time.Duration) DistributedMutex + type ILevelNode interface + GetID func() int64 + GetPid func() int64 + type ImageEXIF struct + Format string + Height int + Latitude decimal.Decimal + Longitude decimal.Decimal + Orientation string + Size int64 + Width int + func ParseImageEXIF(filename string) (*ImageEXIF, error) + type LevelTree struct + Children []*LevelTree[T] + Data T + func BuildLevelTree[T ILevelNode](data map[int64][]T, pid int64) []*LevelTree[T] + type LogConfig struct + Compress bool + Filename string + Level zapcore.Level + MaxAge int + MaxBackups int + MaxSize int + Options []zap.Option + Stderr bool + type Orientation int + const BottomLeft + const BottomRight + const LeftBottom + const LeftTop + const RightBottom + const RightTop + const TopLeft + const TopRight + func (o Orientation) String() string + type Quantity int64 + func (q Quantity) String() string + type Rect struct + H int + W int + X int + Y int + type SQLBuilder interface + Transaction func(ctx context.Context, f func(ctx context.Context, tx TXBuilder) error) error + func NewSQLBuilder(db *sqlx.DB, logFn func(ctx context.Context, query string, args ...any)) SQLBuilder + type SQLClause struct + func SQLExpr(query string, binds ...any) *SQLClause + type SQLOption func(w *sqlWrapper) + func CrossJoin(table string) SQLOption + func Distinct(columns ...string) SQLOption + func FullJoin(table, on string) SQLOption + func GroupBy(columns ...string) SQLOption + func Having(query string, binds ...any) SQLOption + func Join(table, on string) SQLOption + func LeftJoin(table, on string) SQLOption + func Limit(n int) SQLOption + func Offset(n int) SQLOption + func OrderBy(columns ...string) SQLOption + func Returning(columns ...string) SQLOption + func RightJoin(table, on string) SQLOption + func Select(columns ...string) SQLOption + func Table(name string) SQLOption + func Union(wrappers ...SQLWrapper) SQLOption + func UnionAll(wrappers ...SQLWrapper) SQLOption + func Where(query string, binds ...any) SQLOption + func WhereIn(query string, binds ...any) SQLOption + type SQLWrapper interface + All func(ctx context.Context, data any) error + BatchInsert func(ctx context.Context, data any) (sql.Result, error) + Delete func(ctx context.Context) (sql.Result, error) + Insert func(ctx context.Context, data any) (sql.Result, error) + One func(ctx context.Context, data any) error + Truncate func(ctx context.Context) (sql.Result, error) + Update func(ctx context.Context, data any) (sql.Result, error) + type Step struct + Head int + Tail int + func Steps(total, step int) (steps []Step) + type TXBuilder interface + Wrap func(opts ...SQLOption) SQLWrapper + type X map[string]any