ling-base

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT

README

ling-base

Go 基础工具库。采用多 module 按需引入:业务只 import 用到的驱动,不会把无关 SDK 拉进依赖树。

模块结构

ling-base/
├─ go.mod / go.work          # 仓库锚点 + 本地多 module 开发
├─ logger/                   # 结构化日志(zap + lumberjack)
├─ constants/                # 全局常量
│
├─ cache/                    # module: .../cache  (接口 + 纯标准库实现)
│  ├─ lru / memory / noop / multilevel
│  ├─ bigcache/              # 独立 module,依赖 allegro/bigcache
│  ├─ redis/                 # 独立 module,依赖 go-redis
│  ├─ memcache / freecache / ristretto
│
├─ lock/                     # module: .../lock   (接口 + memory)
│  ├─ redis / redlock / etcd / zookeeper / consul / mysql / postgres
│
├─ bloom/                    # module: .../bloom  (接口 + 估算 + 共享哈希)
│  ├─ memory / counting / scalable   # 独立 module,纯标准库
│  └─ redis / redisbloom      # 独立 module,依赖 go-redis
│
├─ captcha/                  # module: .../captcha (验证码:滑块/点选/拼图/算术/旋转)
│
├─ censor/                   # module: .../censor  (内容审核接口)
│  ├─ aliyun/                # 独立 module,依赖阿里云 SDK
│  ├─ qcloud/                # 独立 module,依赖腾讯云 SDK
│  └─ qiniu/                 # 独立 module,依赖七牛 SDK
│
├─ stores/                   # module: .../stores  (对象存储接口)
│  ├─ local/                 # 本地文件系统(零云 SDK)
│  ├─ s3/ oss/ cos/ minio/   # 独立 module,各引各的 SDK
│  └─ kodo/ tos/ obs/ ks3/
│
└─ i18n/                     # module: .../i18n   (国际化:翻译 + 格式化 + locale 检测)
   ├─ gin/                   # 独立 module,Gin 中间件
   └─ mymemory/              # 独立 module,MyMemory 机器翻译

本地开发使用已提交的 go.work;发布后消费者不需要 go.work,直接 go get 子模块即可。

按需安装示例

# 只要 LRU(零第三方依赖)
go get github.com/LingByte/ling-base/cache

# 只要 BigCache 驱动(只会拉 bigcache + cache 抽象)
go get github.com/LingByte/ling-base/cache/bigcache

# 只要 Redis 分布式锁
go get github.com/LingByte/ling-base/lock/redis

# 只要 S3 对象存储
go get github.com/LingByte/ling-base/stores/s3

# 只要 i18n 核心(零外部依赖)
go get github.com/LingByte/ling-base/i18n

# 要 Gin i18n 中间件
go get github.com/LingByte/ling-base/i18n/gin
import (
    "github.com/LingByte/ling-base/cache"
    "github.com/LingByte/ling-base/cache/bigcache" // 不会间接引入 redis/etcd/...
)

文档

开发

go work sync

# 测试所有模块(根模块 + 子模块各自独立测试)
go test ./...
for mod in $(find . -name go.mod -not -path ./go.mod | xargs -I{} dirname {}); do
  (cd "$mod" && go test ./...)
done

# 格式化
gofmt -w .

# vet
go vet ./...

Directories

Path Synopsis
apidocs module
bootstrap module
cache module
redis module
captcha module
common module
audioutil module
authcontext module
barcode module
cache module
cache/redis module
compress module
config module
constants module
convert module
cron module
crypto module
eventbus module
geoip module
hash module
i18n module
i18n/gin module
i18n/mymemory module
idgen module
imageutil module
jwtutil module
jwtutil/gin module
limiter module
limiter/count module
lock module
logger module
logger/gin module
mathutil module
metrics module
middleware module
migration module
mq module
mq/activemq module
netutil module
nltime module
notification module
opentelemetry module
parser module
password module
payment module
payment/creem module
payment/epay module
payment/waffo module
pinyin module
pool module
qrcode module
queue module
queue/memory module
random module
rbac module
response module
response/gin module
retry module
sanitize module
scheduler module
search module
search/bleve module
stats module
stats/file module
stats/gin module
stats/memory module
stats/redis module
system module
timeutil module
tracing module
validate module
videoutil module
constants module
eventbus module
memory module
i18n module
gin module
mymemory module
lingcli module
Package logger provides structured logging for LingByte.
Package logger provides structured logging for LingByte.
gin module
metrics module
mq module
activemq module
kafka module
rabbitmq module
redisstream module
rocketmq module
notification module
email module
inbox module
parser module
providers
ocr module
queue module
memory module
realtime module
aliyunomni module
volcdialogue module
relay module
relaykit module
scheduler module
search module
bleve module
stores module
cos module
kodo module
ks3 module
local module
minio module
obs module
oss module
s3 module
tos module
synthesizer module
aliyun module
aws module
azure module
baidu module
coqui module
elevenlabs module
fishaudio module
fishspeech module
google module
local module
minimax module
openai module
qcloud module
qiniu module
volcengine module
xunfei module
tracing module
version module
voice
realtime module
recognizer module
synthesizer module

Jump to

Keyboard shortcuts

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