go-pgsql is a PostgreSQL client library for the Go programming language.
It partially implements version 3.0 of the PostgreSQL frontend/backend protocol, so it should work with servers of version 7.4 and later.
It now supports database/sql in addition to its existing interface.
First make sure you have a working Go installation, see the installation guide at http://golang.org/doc/install.html
Now you should be able to install go-pgsql by running
go get github.com/lxn/go-pgsql
There are some examples in the examples directory which should get you started.
Please open an issue on the bug tracker if you encounter a bug.
go-pgsql is currently missing support for some features, including:
- authentication types other than MD5
- SSL encrypted sessions
- some data types like bytea, ...
- canceling commands/queries
- bulk copy
- ...
To connect, you must pass a connection string to pgsql.Connect(). Much as with the libpq conninfo parameter, values are optional, and may be overridden by environment variables at runtime, specifically:
- PGPORT - port number
- PGUSER - user name (defaults to postgres)
- PGHOST - host name/address (defaults to localhost)
- PGDATABASE - name of database (defaults to user name if not specified)