netrc

package module
v0.0.0-...-b36f1c5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: MIT Imports: 10 Imported by: 0

README

netrc Build Status GoDoc

A netrc parser for Go.

Usage

Getting credentials for a host.

usr, err := user.Current()
n, err := netrc.Parse(filepath.Join(usr.HomeDir, ".netrc"))
fmt.Println(n.Machine("api.heroku.com").Get("password"))

Setting credentials on a host.

usr, err := user.Current()
n, err := netrc.Parse(filepath.Join(usr.HomeDir, ".netrc"))
n.Machine("api.heroku.com").Set("password", "newapikey")
n.Save()

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidNetrc = errors.New("Invalid netrc")

ErrInvalidNetrc means there was an error parsing the netrc file

Functions

This section is empty.

Types

type Machine

type Machine struct {
	Name      string
	IsDefault bool
	// contains filtered or unexported fields
}

Machine from the netrc file

func (*Machine) Get

func (m *Machine) Get(name string) string

Get a property from a machine

func (*Machine) Set

func (m *Machine) Set(name, value string)

Set a property on the machine

type Netrc

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

Netrc file

func Parse

func Parse(path string) (*Netrc, error)

Parse the netrc file at the given path It returns a Netrc instance

func (*Netrc) AddMachine

func (n *Netrc) AddMachine(name, login, password string)

AddMachine adds a machine

func (*Netrc) Machine

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

Machine gets a machine by name

func (*Netrc) RemoveMachine

func (n *Netrc) RemoveMachine(name string)

RemoveMachine remove a machine

func (*Netrc) Render

func (n *Netrc) Render() string

Render out the netrc file to a string

func (*Netrc) Save

func (n *Netrc) Save() error

Save the file to disk

Jump to

Keyboard shortcuts

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