Skip to content

cybergarage/go-postgresql

Repository files navigation

go-postgresql

GitHub tag (latest SemVer) test Go Reference codecov

go-postgresql is a framework for building PostgreSQL compatible servers in Go.

Overview

go-postgresql implements the PostgreSQL wire protocol and automatically interprets the major message flow (startup, authentication, parameter/status, etc.). This lets you focus on implementing your own DDL (Data Definition Language) and DML (Data Manipulation Language) logic instead of re‑implementing the protocol machinery.

All startup and system messages are handled for you. Provide implementations for the SQL execution interfaces and you have a functioning PostgreSQL‑compatible server.

Features

Core capabilities provided by go-postgresql:

  • Full PostgreSQL wire protocol handling (startup, authentication prompts, message flow, ready states)
  • Pluggable SQL execution via the go-sqlparser executor interface
  • Extensible authentication (password / TLS client cert integration via go-authenticator)
  • Structured error response generation matching PostgreSQL fields
  • COPY (simple) stream handling helpers
  • Prepared statement and portal management
  • Tracing hooks (span start/finish) using go-tracing
  • Modular connection and message reader abstractions
  • Integration helpers for system catalog style queries

Optional integrations (via related Cybergarage projects):

  • Test harness utilities (go-sqltest)
  • Safe numeric and type conversion (go-safecast)
  • SASL authentication flows (go-sasl)
  • Deterministic logging and debugging (go-logger)

Table of Contents

Examples

Representative example projects built with go-postgresql:

Quick Docker Run (Examples)

Run the example in‑memory server (go-postgresqld) locally:

docker run --rm -p 5432:5432 cybergarage/go-postgresqld:latest

Connect using psql (requires it installed):

psql "host=127.0.0.1 port=5432 user=postgres sslmode=disable"

Run the PuzzleDB example image:

docker run --rm -p 5432:5432 cybergarage/puzzledb:latest

Tip: Use -e POSTGRES_INIT=... (if the image supports custom init scripts) or mount volumes for persistence in extended setups.

Related Projects

go-postgresql is developed in collaboration with other Cybergarage libraries:

References

About

No description, website, or topics provided.

Resources

License

Stars

4 stars

Watchers

2 watching

Forks

Packages

 
 
 

Contributors