推荐指数 44.3
← 返回 2026.11.22 日报
日报快照 · Daily Snapshot
NO. 021

用 Go 直接写 PostgreSQL 扩展

#ARTICLE HackerNews 2026.11.22
推荐指数 51.0 NO. 021 · 2026.11.22
发布2026/11/21Score102Comments14

gopgext 让开发者用纯 Go 代码(通过 TinyGo 编译)编写 PostgreSQL 扩展,自动生成 C 粘合层和安装脚本。对 AI 工程师意味着可以用 Go 的标准库和类型安全来构建数据库原生功能,而不用碰 C 或 Rust。

PostgreSQL 扩展开发长期被 C 和 Rust(pgx)垄断,Go 生态一直缺席。gopgext 的突破口是 TinyGo 的 WASM 级编译体积,生成的 .so 比传统 C 扩展更轻,且 Go 的并发模型和错误处理比 C 安全得多。

跟 pgx(Rust 框架)比,gopgext 牺牲了部分极致性能,但换来了团队已有的 Go 技术栈和更快的迭代速度。如果你的团队已经在用 Go 写后端,需要自定义聚合函数或触发器来处理 AI 流水线的数据清洗逻辑,这个工具能省掉跨语言维护的麻烦。

目前支持 SPI 查询和取消响应,但 GiST/GIN 索引访问方法的文档还不完整,生产环境建议先从简单的 SQL 函数和触发器入手验证稳定性。

意见分歧 14 条评论

核心争论:Go写PG扩展是否必要,还是直接用LLM生成plpgsql或选Rust/pgrx更务实

3eb7988a1663

The Go community sold me on the necessity of programming mascots. The gopher is adorable, and I love seeing the creative tweaks for how people incorporate it into their marketing. Ferris the crab also seems like it has been around since the early days, but I do not see nearly as many projects with c

angrydingo

for code snippets on darkmode i can't see bracket

Wicher

See also https://gitlab.com/microo8/plgo

替代方案: plpgsqlplv8pljsRustpgrxpgrustClickHouseTimescaleDB
查看原文 →