Skip to content

Google UUID type support for pgx PostgreSQL driver

License

Notifications You must be signed in to change notification settings

vgarvardt/pgx-google-uuid

Repository files navigation

pgx-google-uuid

github.com/google/uuid type support for github.com/jackc/pgx PostgreSQL driver

Major package version corresponds to the major pgx version, e.g.:

  • github.com/vgarvardt/pgx-google-uuid/v4 -> github.com/jackc/pgx/v4
  • github.com/vgarvardt/pgx-google-uuid/v5 -> github.com/jackc/pgx/v5

Usage example

package main

import (
  "context"
  "os"

  "github.com/jackc/pgx/v5"
  "github.com/jackc/pgx/v5/pgxpool"
  pgxUUID "github.com/vgarvardt/pgx-google-uuid/v5"
)

func main() {
  pgxConfig, err := pgxpool.ParseConfig(os.Getenv("PG_URI"))
  if err != nil {
    panic(err)
  }

  pgxConfig.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
    pgxUUID.Register(conn.TypeMap())
    return nil
  }

  pgxConnPool, err := pgxpool.NewWithConfig(context.TODO(), pgxConfig)
  if err != nil {
    panic(err)
  }

  // use pgxConnPool
  ...
}

About

Google UUID type support for pgx PostgreSQL driver

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages