pgx-pg-uint128
pgx-pg-uint128 adds support for the pg-uint128 PostgreSQL extension in
the Go pgx driver.
Requirements
- PostgreSQL 12+ with the pg-uint128 extension installed
pgx driver version 5.6.0+
Go version 1.21+
Features
Installation
To add pgx-pg-uint128 to your Go project, run:
go get github.com/pg-uint/pgx-pg-uint128
Usage
package main
import (
"context"
"log"
"os"
"github.com/jackc/pgx/v5"
"github.com/pg-uint/pgx-pg-uint128/types"
"github.com/pg-uint/pgx-pg-uint128/types/zeronull"
)
func main() {
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatalf("Unable to connect to database: %v", err)
}
defer conn.Close(context.Background())
if _, err := types.RegisterAll(context.Background(), conn); err != nil {
log.Fatalf("Unable to register types: %v", err)
}
// Optionally register zeronull types
zeronull.Register(conn.TypeMap())
// Do regular work with connection
}
- See this example for pgx: example
- See these examples for pgxpool: