Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 926 Bytes

README.md

File metadata and controls

45 lines (30 loc) · 926 Bytes

go-pghelpers

Golang helpers for Postgres.

Installation

go get github.com/neighborly/go-pghelpers

Usage

PostgresConfig

PostgresConfig holds the information for postgres database connection. For example

var postgresConfig = pghelpers.PostgresConfig{
	Host:       "localhost",
	Port:       5432,
	Username:   "postgres",
	Password:   "",
	Database:   "postgres",
}

Connect Postgres

pghelpers.ConnectPostgres function returns db object and error if any. You can use pghelpers.ConnectPostgres as follows

db, err := pghelpers.ConnectPostgres(postgresConfig)

GenerateAddress

GenerateAddress returns a Postgres connection string, which can be used for sql.open().

addr := postgresConfig.GenerateAddress()

License

This project is licensed under the MIT License.