Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
Check to see if the file exists at the given path
func FilePath ¶
Creates a file path based on the passed string
if the empty string is passed $HOME/.netrc is used if a filename is passed ex: .mynetrc it is assumed to be in your $HOME directory, ex: $HOME/.mynetrc if a path starting with a / is passed it is used without modification this uses path/filepath's Join(...) function so you can also pass relative paths ex: "../.netrc" would return /Users/.netrc on OS X
func ValidPermissions ¶
Check the file permissions at the given path
600 is valid, all others are invalid returns false if there is an issue with the path
Types ¶
type Netrc ¶
A struct for the Netrc
Path is the netrc filepath Creds is a map of string keys that have pointers to Cred structs The keys relate to the service name from the netrc or 'default' ex: 'machine github.com' Then the key is github.com
func Open ¶
Opens the given path if it exists If the path is invalid a fatal error is thrown A new Netrc is created and the file is read into the Creds map A pointer to the Netrc will always be returned
func OpenDefault ¶
func OpenDefault() *Netrc
A convenience method for opening the default .netrc
Probably in $HOME/.netrc
func (*Netrc) GetValue ¶
Get a username and password for a service
This must be called from a valid netrc instace that has been Read
Params
key: the string following machine in the netrc that identifies the service def: pass true if you want the default credentials (if they exist) if there aren't any credentials for the given key
Return
string: the username string: the password error: an error if one occurs either because of a no credentials or an invalid key
Click to show internal directories.
Click to hide internal directories.