pgpassfile

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pgpassfile is a parser PostgreSQL .pgpass files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Hostname string
	Port     string
	Database string
	Username string
	Password string
}

Entry represents a line in a PG passfile.

type Passfile

type Passfile struct {
	Entries []*Entry
}

Passfile is the in memory data structure representing a PG passfile.

func ParsePassfile

func ParsePassfile(r io.Reader) (*Passfile, error)

ParsePassfile reads r and parses it into a Passfile.

func ReadPassfile

func ReadPassfile(path string) (*Passfile, error)

ReadPassfile reads the file at path and parses it into a Passfile.

func (*Passfile) FindPassword

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL