Skip to content

Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via github.com/twpayne/go-geos.

License

Notifications You must be signed in to change notification settings

twpayne/pgx-geos

Repository files navigation

pgx-geos

PkgGoDev

Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via github.com/twpayne/go-geos.

Usage

Single connection

import (
    // ...

    "github.com/jackc/pgx/v5"
    "github.com/twpayne/go-geos"
    pgxgeos "github.com/twpayne/pgx-geos"
)

// ...

    connectionStr := os.Getenv("DATABASE_URL")
    conn, err := pgx.Connect(context.Background(), connectionStr)
    if err != nil {
        return err
    }
    if err := pgxgeos.Register(ctx, conn, geos.NewContext()); err != nil {
        return err
    }

Connection pool

import (
    // ...

    "github.com/jackc/pgx/v5/pgxpool"
)

// ...

    config, err := pgxpool.ParseConfig(connectionStr)
    if err != nil {
        return err
    }
    config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
        if err := pgxgeos.Register(ctx, conn, geos.NewContext()); err != nil {
            return err
        }
        return nil
    }

    pool, err := pgxpool.NewWithConfig(context.Background(), config)
    if err != nil {
        return err
    }

License

MIT

About

Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via github.com/twpayne/go-geos.

Topics

Resources

License

Stars

Watchers

Forks

Languages