gopgext enables the creation of PostgreSQL extensions directly from Go code. By marking a Go function with `//gopgext:function`, it becomes a SQL function. The tool handles the generation of necessary C glue code, installation scripts, and control files, abstracting away the complexities of traditional extension development.
Projects using gopgext are standard Go files, supporting the Go standard library including `fmt`, `regexp`, `encoding/json`, and `crypto/*`, along with generics and iterators. Go data types such as strings, numbers, arrays, UUIDs, and JSON map directly to corresponding SQL types. Developers can also define custom data types and composite types in Go.
Beyond simple functions, gopgext supports the creation of triggers, aggregates, various GiST, GIN, SP-GiST, and BRIN operator classes, index access methods, foreign data wrappers, and query hooks. This broad support allows for complex PostgreSQL functionality to be implemented in Go.
The tool's effectiveness has been demonstrated through ports of PostgreSQL's `contrib` modules, including `pgcrypto`, `hstore`, and `pg_stat_statements`, which successfully pass upstream regression tests. gopgext ensures safe operation by allowing multiple Go extensions to load in a single backend, preventing PostgreSQL errors from unwinding through Go frames, and copying results into PostgreSQL memory.
gopgext utilizes a similar architectural approach to gokm, a sibling project that builds Linux kernel modules from Go. This involves a custom TinyGo target and runtime layer for the host environment, a C runtime compiled by the host's build system (PGXS for PostgreSQL), and generated glue code to bridge Go and the host system.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
gopgext allows developers to write PostgreSQL extensions in Go, leveraging TinyGo to compile plain Go code into SQL functions and other extension types. This tool automates the generation of C glue code, install scripts, and control files, simplifying the development of PostgreSQL extensions with Go's standard library features.