Skip to content

pgGo v0.1.0

Choose a tag to compare

@alexshapalov alexshapalov released this 30 Sep 03:00
· 4 commits to main since this release

pgGo is now a Go library as well as a CLI. The pggo command is rebuilt on the same core, with an unchanged JSON contract. PgBot now runs on this library instead of pgx.

go get github.com/pgrundev/pggo@v0.1.0                 # library
go install github.com/pgrundev/pggo/cmd/pggo@v0.1.0    # CLI

Library (github.com/pgrundev/pggo)

  • Connect / ParseConfig read URLs, key=value strings, PG* environment variables, service files and .pgpass. They take ReadOnly(), StatementTimeout() and LockTimeout() options, and a Config.DialFunc for custom dialers such as SSH tunnels.
  • Query streams rows (Next/Scan/Values/RawValues/Err/Close); there are also QueryRow + ErrNoRows, Exec → CommandTag.RowsAffected(), SimpleQuery, Prepare/Deallocate and MaxRows(n).
  • BeginTx(ctx, TxOptions{ReadOnly: true}): BEGIN travels with the first statement in the same sync, so the statement can never run outside the transaction, and it costs no extra round trip.
  • CollectStructs[T] / CollectOneStruct[T] map rows onto structs using db:"…" tags; CollectStructsByPos[T] maps by position.
  • Unknown PostgreSQL types never fail: scan them into *string or *pggo.RawValue.
  • *pggo.PgError carries the SQLSTATE, detail, hint and position.
  • Every call takes a context.Context. When it's cancelled, pgGo sends a cancel request and closes the connection, so the connection can never be reused in an unknown state.
  • A deliberately minimal Pool: max connections, max lifetime, and AfterConnect/BeforeClose hooks.
  • Still zero dependencies (standard library only).

CLI

  • The JSON contract, limits, timeouts and hints are unchanged, and the full regression suite passes on PostgreSQL 16–19.
  • Fix: a connection closed during the handshake is now reported as connection_error.

Verification

  • The library and CLI suites pass on PostgreSQL 16, 17, 18 and 19beta1, with the race detector clean and 7 fuzz targets.
  • PgBot's suites pass on pgGo across PostgreSQL 13–19, over TLS, and through PgBouncer (transaction mode) and PgDog.
  • Agent tests: 6/6.
  • Performance matches v0.0.1 within noise. The binary is 4.10 MB (+1.7%) and peak RSS 6.4 MiB.

The PgBot compatibility audit is in docs/pgbot-compatibility.md.