Entry represents a line in a PG passfile.
type Entry struct { Hostname string Port string Database string Username string Password string }
Passfile is the in memory data structure representing a PG passfile.
type Passfile struct { Entries []*Entry }
func ParsePassfile(r io.Reader) (*Passfile, error)
ParsePassfile reads r and parses it into a Passfile.
func ReadPassfile(path string) (*Passfile, error)
ReadPassfile reads the file at path and parses it into a Passfile.
func (pf *Passfile) FindPassword(hostname, port, database, username string) (password string)
FindPassword finds the password for the provided hostname, port, database, and username. For a Unix domain socket hostname must be set to "localhost". An empty string will be returned if no match is found.
See https://www.postgresql.org/docs/current/libpq-pgpass.html for more password file information.