netrc

package module
v0.0.0-...-9e3ce21 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址