Documentation ¶
Overview ¶
Package pgpass allows for iterating all entries in pgpass (postgresql password file) file as well as easily accessing passwords for a given host and username.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotEnoughFields = errors.New("Not enough fields")
ErrNotEnoughFields indicates line doesn't contain enough fields
Functions ¶
func OpenDefault ¶
OpenDefault opens default pgpass file, which is ~/.pgpass. Current homedir will be retrieved by calling user.Current or using $HOME on failure.
func Password ¶
Password reads password for given host and user from a default pgpass file. Host should be of the form "hostname:port".
func PasswordFrom ¶
PasswordFrom reads password for given host and user from r, which should be in a valid pgpass format. Host should be of the form "hostname:port".
Types ¶
type Entry ¶
type Entry struct {
Hostname, Port, Database, Username, Password string
}
Entry represents single entry in pgpass file
type EntryReader ¶
type EntryReader struct {
// contains filtered or unexported fields
}
EntryReader reads entries from pgpass file
func NewEntryReader ¶
func NewEntryReader(r io.Reader) *EntryReader
NewEntryReader returns new entry reader from provided r
func (*EntryReader) Err ¶
func (er *EntryReader) Err() error
Err returns underlying error if any. Should be checked after unsuccessful call to Next().
func (*EntryReader) Next ¶
func (er *EntryReader) Next() (ok bool)
Next reads in next entry and returns true on success