Documentation
Everything about building PostgreSQL extensions in Go with gopgext.
gopgext builds PostgreSQL extensions from plain Go code, using TinyGo. A
project is just Go files: functions marked with //gopgext:function become
SQL functions, and gopgext supplies everything else: the C glue, the
CREATE FUNCTION script and the control file. Go’s standard library works
(fmt, strings, regexp, encoding/json, crypto/*, maps, generics,
defer/recover, iterators…), and Go code can run queries through SPI.
gopgext is experimental. Don’t use it in production: a bug in the generated code or the Go runtime runs inside the server, where it can crash it or corrupt data, and the API and generated SQL may change without notice.
Start here#
- Installation: requirements and installing the
gopgextcommand. - Tutorial: a “hello world” extension in ten minutes.
Guides#
- Command line:
gopgext init,buildandinstall, and the layout of a project. - SQL functions: how Go functions become SQL functions.
- Data types: new SQL types backed by Go types.
- The pg package: queries, errors, logging and settings.
- Frameworks: triggers, aggregates, indexes, foreign data wrappers, hooks and more.
- Examples and contrib ports: complete extensions to learn from.
Reference#
- API reference: every exported identifier of the Go packages.
- How it works: the build pipeline and the runtime model.
- Limitations: what isn’t supported.
- Development: building gopgext itself and running its tests.
License#
gopgext is released under the MIT License. The contrib ports derive from PostgreSQL’s contrib modules and also keep the PostgreSQL License.