{
  "id": 21082155,
  "title": "PostgreSQL Extensions in Go",
  "url": "https://urgent.news/2026/11/21/postgresql-extensions-in-go",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-21T17:08:04.000Z",
  "source": {
    "name": "Hacker News",
    "slug": "hacker-news",
    "url": "https://jespino.github.io/gopgext/"
  },
  "original_language": "en",
  "account": "PostgreSQL Extensions in Go, a project called gopgext, simplifies the process of building PostgreSQL extensions using Go programming language. By marking functions with //gopgext:function, developers can create SQL functions directly in Go code, with gopgext handling the necessary C glue, install script, and control file. The project utilizes a standard library in Go, including fmt, regexp, encoding/json, crypto/*, maps, generics, iterators, defer/recover, and more. PostgreSQL types like strings, numbers, arrays, NULLs, sets, rows, timestamps, UUIDs, and JSON map seamlessly to Go data types. Developers can define custom data types and composite types in Go as well.\n\nUsing PostgreSQL's SPI interface, gopgext allows developers to write triggers, aggregates, GiST, GIN, SP-GiST, and BRIN operator classes, as well as index access methods, foreign data wrappers, and query hooks. The project even supports ports of PostgreSQL's contrib modules such as pgcrypto, hstore, pg_stat_statements, and cube, which have passed upstream regression tests. Multiple Go extensions can be loaded within a single backend.\n\nNotably, PostgreSQL errors do not unwind through Go frames, ensuring stability. Additionally, results are copied into PostgreSQL memory, preserving performance. gopgext's approach mirrors that of gokm, which builds Linux kernel modules from Go. gopgext achieves this by leveraging a custom TinyGo target and runtime layer for the host, a C runtime compiled by the host's build system (PGXS in PostgreSQL's case), and generated glue code.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}