Day: March 6, 2017

  • Golang: Connect to Postgres and selecting data from a table

    You will need to get the Postgres driver first. In the terminal type: go get github.com/lib/pq Connecting to Postgres package main import ( _ “github.com/lib/pq” “database/sql” “fmt” ) func main() { // Connect to the DB, panic if failed db, err := sql.Open(“postgres”, “postgres://user:password@localhost/dbName?sslmode=disable”) if err != nil { fmt.Println(`Could not connect to db`) panic(err)…