helper

package
v0.0.0-...-b484ebe Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = time.DateTime

Variables

This section is empty.

Functions

func Ajax

func Ajax(msg any, errcode int64, this *pine.Context)

Ajax Ajax返回数据给前端

func App

func App() *pine.Application

App 获取应用实例

func AppPath

func AppPath() string

func ArrayColumn

func ArrayColumn[T any, I any](items []T, field string) []I

ArrayColumn 从items中获取元素值

func ArrayUnique

func ArrayUnique[T comparable](items []T) []T

ArrayUnique 对切片去重

func Bytes2String

func Bytes2String(b []byte) *string

func Cache

func Cache() contracts.Cache

Cache 获取缓存服务

func CondOr

func CondOr[T any](condition bool, trueValue, falseValue T) T

CondOr 常用类型default判断

func ConvertTo

func ConvertTo[S any, T any](input *S, cbs ...func(*T, *S)) (*T, error)

ConvertTo 对结构体做copy转换

func ConvertToAnySlice

func ConvertToAnySlice[T any](s []T) []any

func GetCallerFuncName

func GetCallerFuncName() string

GetCallerFuncName 获取当前执行函数名 只用于日志记录

func GetLocation

func GetLocation() *time.Location

func GetMd5

func GetMd5(str string) string

GetMd5 md5加密字符串

func GetORM

func GetORM() *xorm.Engine

func GetRandomString

func GetRandomString(l int) string

func GetRootPath

func GetRootPath(relPath ...string) string

GetRootPath 获取项目根目录 (即 main.go的所在位置)

func GetTimeStamp

func GetTimeStamp() int

GetTimeStamp 获取时间戳

func GetUrlPrefix

func GetUrlPrefix(catid int64) string

获取Url前缀

func HandleArtListInfo

func HandleArtListInfo(list []map[string]string, titlelen int)

处理文章列表信息数据. 补全一些cms生成

func HasZero

func HasZero(values ...any) bool

HasZero 常用类型零值判断

func InArray

func InArray[T comparable](item T, items []T) bool

InArray 判断元素是否在切片中

func Inject

func Inject(key any, v any, single ...bool)

Inject 注入依赖

func IsFalse

func IsFalse(args ...any) bool

IsFalse 检测字段是否为 空 0 nil

func IsWindows

func IsWindows() bool

func IsZero

func IsZero(t any) bool

IsZero 常用类型零值判断

func Krand

func Krand(size int, kind int) []byte

Krand 随机字符串

func NewOrmLogFile

func NewOrmLogFile(path string) *os.File

func NowDate

func NowDate(str string) string

NowDate 当前时间 Y m d H:i:s

func Or

func Or[T any](a T, b T) T

Or 常用类型default判断

func PanicErr

func PanicErr(err error, msg ...string)

PanicErr 抛出异常

func Password

func Password(password, encrypt string) string

Password 生成密码

func Recover

func Recover()

Recover 捕捉执行协程的异常

func Slog

func Slog(ctxs ...context.Context) *slog.Logger

Slog 获取slog对象

func ToInterfaces

func ToInterfaces(values any) []any

func ToTableTime

func ToTableTime(t string) tables.LocalTime

func UcFirst

func UcFirst(str string) string

Types

type DirInfo

type DirInfo struct {
	Label    string `json:"label"`
	FullPath string `json:"full_path"`
	IsDir    bool   `json:"is_dir"`
	Children any    `json:"children"`
}

func DirTree

func DirTree(dir string) []DirInfo

type EmailOpt

type EmailOpt struct {
	Title        string
	UrlOrMessage string
	Address      []string
}

type Page

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

func NewPage

func NewPage(urlPrefix string, curPage, prePage, total int, params map[string][]string, dynamic bool) *Page

func (*Page) GetFirst

func (p *Page) GetFirst() string

func (*Page) GetLast

func (p *Page) GetLast() string

func (*Page) GetNext

func (p *Page) GetNext() string

func (*Page) GetPrev

func (p *Page) GetPrev() string

func (*Page) HasNext

func (p *Page) HasNext() bool

func (*Page) HasPrev

func (p *Page) HasPrev() bool

func (*Page) String

func (p *Page) String() string

Jump to

Keyboard shortcuts

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