gopgext builds Go extensions for PostgreSQL
gopgext is an open-source tool and runtime overlay that compiles plain Go code into PostgreSQL extensions using TinyGo. It automatically generates the required C glue, SQL function signatures, and control files, letting developers run Go functions natively inside Postgres backend processes.
Writing PostgreSQL extensions in C has always been high-friction, and gopgext makes database-level logic far more accessible for Go teams. While running inside single-threaded backend processes precludes goroutines, it opens up practical in-database data transformation without C memory footguns.
- –Compiles Go via TinyGo with a custom pgext runtime overlay, mapping Go functions directly to Postgres SQL functions via simple comment annotations.
- –Eliminates manual C wrapper boilerplate by auto-generating PGXS build files, SQL migration scripts, and extension control files.
- –Integrates with Postgres's Server Programming Interface (SPI) for executing internal queries, error reporting via SQLSTATE codes, and server logging.
- –Memory isolation relies on a reserved mmap heap with TinyGo's conservative garbage collector, copying final results into Postgres-managed memory.
- –Follows creator Jesús Espino's gokm project (Go for Linux kernel modules), highlighting TinyGo's growing role in embedded and systems programming.
DISCOVERED
10m ago
2026-11-21
PUBLISHED
3h ago
2026-11-21
RELEVANCE
AUTHOR
valyala