go-netrc: github.com/bgentry/go-netrc/netrc Index | Files

package netrc

import "github.com/bgentry/go-netrc/netrc"

Index

Package Files

netrc.go

type Error Uses

type Error struct {
    LineNum int    // Line number
    Msg     string // Error message
}

Error represents a netrc file parse error.

func (*Error) BadDefaultOrder Uses

func (e *Error) BadDefaultOrder() bool

func (*Error) Error Uses

func (e *Error) Error() string

Error returns a string representation of error e.

type Machine Uses

type Machine struct {
    Name     string
    Login    string
    Password string
    Account  string
    // contains filtered or unexported fields
}

Machine contains information about a remote machine.

func FindMachine Uses

func FindMachine(filename, name string) (m *Machine, err error)

FindMachine parses the netrc file identified by filename and returns the Machine named by name. If a problem occurs parsing the file at filename, an error is returned. If a machine named by name exists, it is returned. If no Machine with name name is found and there is a “default” machine, the “default” machine is returned. Otherwise, nil is returned.

func (*Machine) IsDefault Uses

func (m *Machine) IsDefault() bool

IsDefault returns true if the machine is a "default" token, denoted by an empty name.

func (*Machine) UpdateAccount Uses

func (m *Machine) UpdateAccount(newaccount string)

UpdateAccount sets the login for the Machine m.

func (*Machine) UpdateLogin Uses

func (m *Machine) UpdateLogin(newlogin string)

UpdateLogin sets the login for the Machine m.

func (*Machine) UpdatePassword Uses

func (m *Machine) UpdatePassword(newpass string)

UpdatePassword sets the password for the Machine m.

type Macros Uses

type Macros map[string]string

Macros contains all the macro definitions in a netrc file.

type Netrc Uses

type Netrc struct {
    // contains filtered or unexported fields
}

func Parse Uses

func Parse(r io.Reader) (*Netrc, error)

Parse parses from the the Reader r as a netrc file and returns the set of machine information and macros defined in it. The “default” machine, which is intended to be used when no machine name matches, is identified by an empty machine name. There can be only one “default” machine.

If there is a parsing error, an Error is returned.

func ParseFile Uses

func ParseFile(filename string) (*Netrc, error)

ParseFile opens the file at filename and then passes its io.Reader to Parse().

func (*Netrc) FindMachine Uses

func (n *Netrc) FindMachine(name string) (m *Machine)

FindMachine returns the Machine in n named by name. If a machine named by name exists, it is returned. If no Machine with name name is found and there is a “default” machine, the “default” machine is returned. Otherwise, nil is returned.

func (*Netrc) MarshalText Uses

func (n *Netrc) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface to encode a Netrc into text format.

func (*Netrc) NewMachine Uses

func (n *Netrc) NewMachine(name, login, password, account string) *Machine

func (*Netrc) RemoveMachine Uses

func (n *Netrc) RemoveMachine(name string)

Package netrc imports 10 packages (graph) and is imported by 37 packages. Updated 2019-05-27. Refresh now. Tools for package owners.