uuid

package module
v5.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2024 License: MIT Imports: 3 Imported by: 31

README

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
  ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(tm *pgtype.Map)

Register registers the github.com/google/uuid integration with a pgtype.Map.

func TryWrapUUIDEncodePlan

func TryWrapUUIDEncodePlan(value any) (plan pgtype.WrappedEncodePlanNextSetter, nextValue any, ok bool)

TryWrapUUIDEncodePlan implements pgtype.TryWrapEncodePlanFunc interface

func TryWrapUUIDScanPlan

func TryWrapUUIDScanPlan(target any) (plan pgtype.WrappedScanPlanNextSetter, nextDst any, ok bool)

TryWrapUUIDScanPlan implements pgtype.TryWrapScanPlanFunc

Types

type NullUUID

type NullUUID uuid.NullUUID

NullUUID pgx type wrapper for google/uuid.NullUUID

func (*NullUUID) ScanUUID

func (u *NullUUID) ScanUUID(v pgtype.UUID) error

ScanUUID implements pgtype.UUIDScanner interface

func (NullUUID) UUIDValue

func (u NullUUID) UUIDValue() (pgtype.UUID, error)

UUIDValue implements pgtype.UUIDValuer interface

type UUID

type UUID uuid.UUID

UUID pgx type wrapper for google/uuid.UUID

func (*UUID) ScanUUID

func (u *UUID) ScanUUID(v pgtype.UUID) error

ScanUUID implements pgtype.UUIDScanner interface

func (UUID) UUIDValue

func (u UUID) UUIDValue() (pgtype.UUID, error)

UUIDValue implements pgtype.UUIDValuer interface

type UUIDCodec

type UUIDCodec struct {
	pgtype.UUIDCodec
}

UUIDCodec pgx type wrapper for pgtype.Codec

func (UUIDCodec) DecodeValue

func (UUIDCodec) DecodeValue(tm *pgtype.Map, oid uint32, format int16, src []byte) (any, error)

DecodeValue implements pgtype.Codec interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL