Introducing pq, a pure PostgreSQL database driver for Go

In Chapter 4, Simplifying RESTful Services with Popular Go Frameworks, we used a driver package called go-sqlite3 to work with SQLite3. In the same way, pq is a database driver package available for Go. We can install that library system-wide by using the go get command, as follows:

go get github.com/lib/pq

We can also use the dep tool to install this package. We'll use it in this example. Let's look at the steps for installation here:

  1. Create a new project directory called basicExample in GOPATH, as follows:
touch -p $GOPATH/src/github.com/git-user/chapter7/basicExample
  1. Now, traverse to the basicExample directory and use dep to install the pq package in the directory, like this: ...

Get Hands-On RESTful Web Services with Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.