core

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeDefault          = 100
	ErrCodeLoginFailed      = 101
	ErrCodeFrequentRequests = 102
)
View Source
const FTS_SEARCH_END_IDX = "☾†🔮☽"
View Source
const FTS_SEARCH_START_IDX = "☾🔮☽"

Variables

Functions

func AtoISlice

func AtoISlice(originSlice []string) (strSlice []int, err error)

AtoISlice string 切片转换 int 切片

func CreateSlice

func CreateSlice[T int | string | interface{}](length int, value T) []T

CreateSlice 创建指定长度并初始化为相同值的切片

func ItoaSlice

func ItoaSlice(originSlice []int) []string

ItoaSlice int 切片转换 string 切片

func NewSettings

func NewSettings() (s settings, err error)

func NewTmplManager

func NewTmplManager(name string) *tmplManager

func P

func P(err error)

P panic forever

func PanicErr

func PanicErr(message string, code int)

Types

type App

type App struct {
	RootCmd     *cli.App
	O           *orm
	Settings    *settings
	TokenAuth   *jwtauth.JWTAuth
	OssClient   *oss
	Cache       Cache
	TmplManager *tmplManager
	Validator   *Validator
}

func NewApp

func NewApp() *App

func (*App) AddSubcommand

func (app *App) AddSubcommand(cmd *cli.Command)

func (*App) HTML

func (app *App) HTML(w http.ResponseWriter, tmplName string, data any) error

func (*App) InitCache

func (app *App) InitCache() error

func (*App) InitORM

func (app *App) InitORM() error

func (*App) InitOSS

func (app *App) InitOSS() error

func (*App) InitSetting

func (app *App) InitSetting() error

func (*App) InitTmpl

func (app *App) InitTmpl() error

func (*App) InitTokenAuth

func (app *App) InitTokenAuth()

func (*App) InitValidator

func (app *App) InitValidator()

func (*App) IsDev

func (app *App) IsDev() bool

func (*App) JSON

func (app *App) JSON(w http.ResponseWriter, data any) error

func (*App) Run

func (app *App) Run() error

type AtomicLock

type AtomicLock struct {
	// contains filtered or unexported fields
}

简单的 CAS 机制锁

func (*AtomicLock) TryLock

func (l *AtomicLock) TryLock() bool

func (*AtomicLock) Unlock

func (l *AtomicLock) Unlock()

type Cache

type Cache interface {
	// 操作成功返回true
	Set(key string, value any, ttl time.Duration) bool

	// Get 根据key获取值,key不存在返回nil
	Get(key string) any

	// TTL 无过期时间返回-1,key不存在返回 -2
	TTL(key string) time.Duration

	Del(key string) bool
}

func NewCache

func NewCache(addr string) (cache Cache, err error)

type Err

type Err struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewErr

func NewErr(message string, code int) *Err

func (*Err) Error

func (e *Err) Error() string

type SystemSet

type SystemSet struct {
	AttachmentCDN    string        `json:"attachmentCDN"`
	TokenExpiryHours time.Duration `json:"tokenExpiryHours"`
}

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator() *Validator

func (*Validator) Struct

func (v *Validator) Struct(data any) map[string]string

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL