netrc

package
v0.0.0-...-86d2489 Latest Latest
Warning

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

Go to latest
Published: May 15, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error represents a netrc file parse error.

func (*Error) BadDefaultOrder

func (e *Error) BadDefaultOrder() bool

func (*Error) Error

func (e *Error) Error() string

Error returns a string representation of error e.

type Machine

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

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

func (m *Machine) IsDefault() bool

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

func (*Machine) UpdateAccount

func (m *Machine) UpdateAccount(newaccount string)

UpdateAccount sets the login for the Machine m.

func (*Machine) UpdateLogin

func (m *Machine) UpdateLogin(newlogin string)

UpdateLogin sets the login for the Machine m.

func (*Machine) UpdatePassword

func (m *Machine) UpdatePassword(newpass string)

UpdatePassword sets the password for the Machine m.

type Macros

type Macros map[string]string

Macros contains all the macro definitions in a netrc file.

type Netrc

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

func Parse

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

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

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

func (*Netrc) FindMachine

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

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

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

func (*Netrc) NewMachine

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

func (*Netrc) RemoveMachine

func (n *Netrc) RemoveMachine(name string)

func (*Netrc) Save

func (netrc *Netrc) Save() error

Jump to

Keyboard shortcuts

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