Documentation
¶
Index ¶
- func CalculateRealSize(v interface{}) int
- func CamelToSnake(s string) string
- func CheckModelValid(model map[string]any) error
- func CleanMap(m map[string]any) map[string]any
- func CollectToMap[T any, K comparable, V any](in []T, keyOf func(T) K, valOf func(T) V) map[K]V
- func CompileExpr[E any](code string) (*vm.Program, error)
- func ConvertByJSON[A any, B any](input A) (B, error)
- func DeRef(row []interface{}) []interface{}
- func DefaultTemplateRender(inputText string, sourceMap map[string]any, result *string) error
- func DownloadToTempDir(url string) (*os.File, error)
- func Dtr(row interface{}) interface{}
- func Eval[E any](code string, env E) (float64, error)
- func EvalWithTrace[E any](code string, env E) (float64, string, error)
- func FileExists(filePath string) bool
- func Filter[T any](endpoints []T, f func(endpoint T) bool) []T
- func Find[T any](list []T, predicate func(T) bool) (T, bool)
- func FlatMap[T any, R any](in []T, f func(T) []R) []R
- func GenerateShortID() (string, error)
- func GenerateShortIDWithDigits(digits uint8) (string, error)
- func GetByPath(data any, path []any) any
- func GetProgram[E any](code string) (*cachedProgram, error)
- func GetSuffix(str string) string
- func GetValue(data map[string]any, expr string) any
- func GroupBy[T any, K comparable](items []T, keyFn func(T) K) map[K][]T
- func GzipCompress(input []byte) []byte
- func GzipDecompress(input []byte) []byte
- func HashPassword(password string) (string, error)
- func InLike(target any, list any) bool
- func InSlice(target any, list any) bool
- func InitSnowflake(nodeID int64) (*snowflake.Node, error)
- func Int(p *int) int
- func IsDataEmpty(v any) bool
- func IsEmpty(s string) bool
- func MakeStructExtractor[T any](keys []string) func(T) []interface{}
- func MapKeys[M ~map[K]V, K comparable, V any](m M) []string
- func MapNotNull[T any, R any](in []T, f func(T) *R) []R
- func MapToJSON(m map[string]any) (datatypes.JSON, error)
- func MaxMapInt(m map[string]int) (max int, ok bool)
- func MustJSON(v any) datatypes.JSON
- func NumericStringify(v any) string
- func ParseList(v any) []string
- func ParsePathExpr(expr string) []any
- func ParseSmartTime(v any) (time.Time, error)
- func ParseTemplate(templateText string) (map[string]TemplateNeedle, error)
- func ParseTemplateTest()
- func Ptr[T any](v T) *T
- func ReadStringField(m map[string]any, key string) string
- func RegexReplace(s, pattern, repl string) string
- func RenderControlNodes(nodes []Node, model map[string]any) string
- func RenderTemplateStrictly(templateText string, slots map[string]TemplateNeedle, model map[string]any, ...) string
- func RenderTemplateWithControl(input string, model map[string]any) (string, error)
- func RunParallel[I any, O any](ctx context.Context, inputs []I, workers int, rowId func(I) string, ...) (map[string]O, []error)
- func SaveToWAVFile(filename string, data []byte) (*os.File, error)
- func ScryptHash(password, salt string) (string, error)
- func SendFileChunks(file *os.File, firstSize int, chunkSize int, ch chan []byte)
- func SeqToSlice[V any](seq iter.Seq[V]) []V
- func SimplifyHeader(header map[string][]string) map[string]string
- func StreamMap[T any, R any](in []T, f func(T) R) []R
- func StreamMapDistinct[T any, R comparable](in []T, fn func(T) R) []R
- func StreamMapDistinctBy[T any, K comparable](in []T, keyFn func(T) K) []T
- func Stringify[A any](input A) string
- func SumBy[T any](items []T, addFn func(dst *T, src T)) T
- func SumMapBy[T any, K comparable](records []T, keyFn func(T) K, addFn func(dst *T, src T)) map[K]T
- func Ternary[T any](cond bool, trueVal T, falseVal T) T
- func TernaryFunc[T any](cond bool, trueVal func() T, falseVal T) T
- func TimingMiddlewareLogging(phase string, log string) func()
- func ToFloat64(v any) (float64, bool)
- func Unique[T comparable](arr []T) []T
- func UniqueList(items []string) []string
- func UniqueStrings(input []string) []string
- func Uuid() string
- type DebounceManager
- type EchoNode
- type Event
- type EventBus
- type FlexibleFloat64
- type FlexibleInt8
- type FlexibleInt64
- type FlexibleString
- type HandlerFunc
- type IfNode
- type IntTuple
- type KeyFunc
- type LRUCache
- type Node
- type Option
- type PageQueryFunc
- type Pair
- type SafeHashSet
- type SmartTime
- type StringSlice
- type Subscriber
- type TemplateNeedle
- type TextNode
- type Token
- type Topic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelToSnake ¶ added in v0.1.2
func CheckModelValid ¶ added in v0.1.2
CheckModelValid 检查模型中每个键是否合法:非空且只允许英文、数字、下划线以及中文字符
func CollectToMap ¶ added in v0.1.2
func CollectToMap[T any, K comparable, V any]( in []T, keyOf func(T) K, valOf func(T) V, ) map[K]V
func ConvertByJSON ¶ added in v0.0.7
ConvertByJSON Convert 转换任意类型 A 到类型 B
func DefaultTemplateRender ¶ added in v0.1.2
func EvalWithTrace ¶ added in v0.1.9
EvalWithTrace returns the numeric result and the expression string used for compilation. (Using expr v1 API; no AST dump available here.)
func FileExists ¶
func GenerateShortID ¶ added in v0.1.2
func GenerateShortIDWithDigits ¶ added in v0.1.2
func GetProgram ¶ added in v0.1.9
func GroupBy ¶ added in v0.1.6
func GroupBy[T any, K comparable](items []T, keyFn func(T) K) map[K][]T
func GzipCompress ¶
func GzipDecompress ¶
func HashPassword ¶ added in v0.1.2
HashPassword 使用 bcrypt 对密码进行哈希处理
func InitSnowflake ¶ added in v0.1.2
InitSnowflake 初始化 Snowflake 节点
func IsDataEmpty ¶ added in v0.1.2
func MakeStructExtractor ¶ added in v0.1.6
MakeStructExtractor 预编译一个从 struct T 按 keys 提取值的函数(按 json tag 或字段名匹配,支持匿名/嵌套)
func MapKeys ¶ added in v0.1.2
func MapKeys[M ~map[K]V, K comparable, V any](m M) []string
func MapNotNull ¶ added in v0.1.6
func NumericStringify ¶ added in v0.1.2
func ParsePathExpr ¶ added in v0.1.2
ParsePathExpr 将路径字符串(如 用户.好友[0].昵称)解析为 ["用户", "好友", 0, "昵称"]
func ParseSmartTime ¶ added in v0.1.7
ParseSmartTime 自动识别 string / number / timestamp 转换为 time.Time
func ParseTemplate ¶ added in v0.1.2
func ParseTemplate(templateText string) (map[string]TemplateNeedle, error)
ParseTemplate 从模板文本中提取所有占位符,返回键值对:键为参数名称,值为占位符文本
func ParseTemplateTest ¶ added in v0.1.2
func ParseTemplateTest()
func RegexReplace ¶ added in v0.1.2
RegexReplace 用正则表达式将字符串 s 中所有匹配 pattern 的部分替换为 repl
func RenderControlNodes ¶ added in v0.1.7
func RenderTemplateStrictly ¶ added in v0.1.2
func RenderTemplateStrictly(templateText string, slots map[string]TemplateNeedle, model map[string]any, strict bool) string
RenderTemplateStrictly 根据传入的模型,将模板中的占位符替换为实际值
func RenderTemplateWithControl ¶ added in v0.1.7
func RunParallel ¶ added in v0.1.2
func RunParallel[I any, O any]( ctx context.Context, inputs []I, workers int, rowId func(I) string, function func(context.Context, I) (O, error), ) (map[string]O, []error)
RunParallel 并发执行 fn,按输入顺序返回结果。 - inputs: 要处理的输入切片 - workers: 工作者数量(<=0 视为 1) - fn: 你的任务函数,形如 func(ctx, I) (O, error)
func ScryptHash ¶ added in v0.1.2
func SendFileChunks ¶
func SeqToSlice ¶ added in v0.1.6
func SimplifyHeader ¶ added in v0.0.7
SimplifyHeader 压缩 Header
func StreamMapDistinct ¶ added in v0.1.6
func StreamMapDistinct[T any, R comparable](in []T, fn func(T) R) []R
func StreamMapDistinctBy ¶ added in v0.1.9
func StreamMapDistinctBy[T any, K comparable](in []T, keyFn func(T) K) []T
StreamMapDistinctBy 按 keyFn 去重,返回原始元素,保持顺序
func SumMapBy ¶ added in v0.1.6
func SumMapBy[T any, K comparable](records []T, keyFn func(T) K, addFn func(dst *T, src T)) map[K]T
func TernaryFunc ¶ added in v0.1.2
func TimingMiddlewareLogging ¶ added in v0.1.2
func Unique ¶ added in v0.1.7
func Unique[T comparable](arr []T) []T
func UniqueList ¶ added in v0.1.2
func UniqueStrings ¶ added in v0.1.2
Types ¶
type DebounceManager ¶ added in v0.1.7
type DebounceManager struct {
// contains filtered or unexported fields
}
func NewDebounceManager ¶ added in v0.1.7
func NewDebounceManager(delay time.Duration) *DebounceManager
func (*DebounceManager) Debounce ¶ added in v0.1.7
func (m *DebounceManager) Debounce(taskID uint64, fn func(uint64))
type EventBus ¶ added in v0.1.7
type EventBus[T any] struct { // contains filtered or unexported fields }
EventBus manages multiple topics for type T.
func (*EventBus[T]) CreateTopic ¶ added in v0.1.7
CreateTopic creates a topic and returns it.
type FlexibleFloat64 ¶ added in v0.1.2
type FlexibleFloat64 float64
func (*FlexibleFloat64) UnmarshalJSON ¶ added in v0.1.2
func (f *FlexibleFloat64) UnmarshalJSON(b []byte) error
type FlexibleInt8 ¶ added in v0.1.2
type FlexibleInt8 int8
func (*FlexibleInt8) UnmarshalJSON ¶ added in v0.1.2
func (f *FlexibleInt8) UnmarshalJSON(b []byte) error
type FlexibleInt64 ¶ added in v0.1.2
type FlexibleInt64 int64
func (*FlexibleInt64) UnmarshalJSON ¶ added in v0.1.2
func (f *FlexibleInt64) UnmarshalJSON(b []byte) error
type FlexibleString ¶ added in v0.1.6
type FlexibleString string
func (*FlexibleString) UnmarshalJSON ¶ added in v0.1.6
func (s *FlexibleString) UnmarshalJSON(b []byte) error
type HandlerFunc ¶ added in v0.1.2
type HandlerFunc[T any] func(items []T)
type LRUCache ¶ added in v0.1.2
type LRUCache[K comparable, V any] struct { // contains filtered or unexported fields }
LRUCache 是一个并发安全的泛型 LRU 缓存
func NewLRUCache ¶ added in v0.1.2
func NewLRUCache[K comparable, V any](cap int) *LRUCache[K, V]
NewLRUCache 新建一个最大容量为 cap 的 LRUCache
type Node ¶ added in v0.1.7
type Node interface{}
-------- 控制流 AST --------
func ParseControlBlocks ¶ added in v0.1.7
type Option ¶ added in v0.1.2
type Option[K comparable, V any] func(*LRUCache[K, V])
type PageQueryFunc ¶ added in v0.1.2
type SafeHashSet ¶ added in v0.1.2
type SafeHashSet[T comparable] struct { // contains filtered or unexported fields }
func NewSafeHashSet ¶ added in v0.1.2
func NewSafeHashSet[T comparable]() *SafeHashSet[T]
func ScanAllPages ¶ added in v0.1.2
func ScanAllPages[T any]( ctx context.Context, pageSize int, query PageQueryFunc[T], keyFunc KeyFunc[T], handle HandlerFunc[T], ) (*SafeHashSet[string], error)
func (*SafeHashSet[T]) Add ¶ added in v0.1.2
func (s *SafeHashSet[T]) Add(val T)
func (*SafeHashSet[T]) Has ¶ added in v0.1.2
func (s *SafeHashSet[T]) Has(val T) bool
func (*SafeHashSet[T]) Len ¶ added in v0.1.2
func (s *SafeHashSet[T]) Len() int
func (*SafeHashSet[T]) Remove ¶ added in v0.1.2
func (s *SafeHashSet[T]) Remove(val T)
func (*SafeHashSet[T]) Values ¶ added in v0.1.2
func (s *SafeHashSet[T]) Values() []T
type SmartTime ¶ added in v0.1.7
SmartTime 可识别多种时间格式,统一序列化输出格式
func (SmartTime) MarshalJSON ¶ added in v0.1.7
MarshalJSON 统一输出格式
func (*SmartTime) UnmarshalJSON ¶ added in v0.1.7
UnmarshalJSON 可自动识别多种时间格式
type StringSlice ¶ added in v0.1.6
type StringSlice []string
StringSlice 就是一个可以自动 JSON ↔ Go 切片的类型
func (*StringSlice) Scan ¶ added in v0.1.6
func (s *StringSlice) Scan(src any) error
Scan 把数据库中读出来的 JSON 反序列化到 StringSlice
func (StringSlice) ToStringSlice ¶ added in v0.1.6
func (s StringSlice) ToStringSlice() []string
type Subscriber ¶ added in v0.1.7
Subscriber receives events of type T.
type TemplateNeedle ¶ added in v0.1.2
type Topic ¶ added in v0.1.7
type Topic[T any] struct { // contains filtered or unexported fields }
Topic manages subscriptions and publishing for type T.
func (*Topic[T]) DroppedCount ¶ added in v0.1.7
func (*Topic[T]) Publish ¶ added in v0.1.7
Publish sends data to all subscribers and stores it in history.
func (*Topic[T]) Subscribe ¶ added in v0.1.7
func (t *Topic[T]) Subscribe(buffer int) *Subscriber[T]
Subscribe adds a new subscriber with buffer size.
func (*Topic[T]) Unsubscribe ¶ added in v0.1.7
Unsubscribe removes subscriber and closes channel.