A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/cbd16a28eb0a25bc92eb09eb8c7f2b716340fcff below:

Ensure the passfile is used on Windows · orgrim/pg_back@cbd16a2 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+15

-1

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+15

-1

lines changed Original file line number Diff line number Diff line change

@@ -30,6 +30,7 @@ import (

30 30

"errors"

31 31

"fmt"

32 32

"github.com/lib/pq"

33 +

"os"

33 34

"strings"

34 35

"time"

35 36

)

@@ -54,7 +55,20 @@ func pgGetVersionNum(db *sql.DB) (int, error) {

54 55

}

55 56 56 57

func dbOpen(conninfo *ConnInfo) (*pg, error) {

57 -

connstr := conninfo.String()

58 +

// Workaround the limitation of lib/pq that cannot use the passfile

59 +

// keyword and find the default pgpass.conf file on Windows, by setting

60 +

// the PGPASSFILE environment variable. It parses the file but without

61 +

// expanding variables in the path given in PGPASSFILE.

62 +

if passfile, ok := conninfo.Infos["passfile"]; ok {

63 +

if err := os.Setenv("PGPASSFILE", passfile); err != nil {

64 +

l.Warnln("could not set PGPASSFILE environment variable:", err)

65 +

}

66 +

}

67 + 68 +

// lib/pq does not like the passfile keyword either.

69 +

c := conninfo.Del("passfile")

70 + 71 +

connstr := c.String()

58 72

l.Verbosef("connecting to PostgreSQL with: \"%s\"", connstr)

59 73

db, err := sql.Open("postgres", connstr)

60 74

if err != nil {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4