Documentation ¶
Index ¶
- Variables
- func AptGetInstall(packages ...string) error
- func ErrorContextf(err *error, format string, args ...interface{})
- func GetIPv4Address(addresses []net.Addr) (string, error)
- func Gunzip(data []byte) ([]byte, error)
- func Gzip(data []byte) []byte
- func IsValidUUIDString(s string) bool
- func NormalizePath(dir string) string
- func PasswordHash(password string) string
- func RandomBytes(n int) ([]byte, error)
- func RandomPassword() (string, error)
- func ReadYaml(path string, obj interface{}) error
- func ShQuote(s string) string
- func Timeit(action string) func()
- func WriteYaml(path string, obj interface{}) error
- type Attempt
- type AttemptStrategy
- type UUID
Constants ¶
This section is empty.
Variables ¶
var FastInsecureHash = false
FastInsecureHash specifies whether a fast, insecure version of the hash algorithm will be used. Changing this will cause PasswordHash to produce incompatible passwords. It should only be changed for testing purposes - to make tests run faster.
Functions ¶
func AptGetInstall ¶
AptGetInstall runs 'apt-get install packages' for the packages listed here
func ErrorContextf ¶
ErrorContextf prefixes any error stored in err with text formatted according to the format specifier. If err does not contain an error, ErrorContextf does nothing.
func GetIPv4Address ¶
GetIPv4Address iterates through the addresses expecting the format from func (ifi *net.Interface) Addrs() ([]net.Addr, error)
func IsValidUUIDString ¶
IsValidUUIDString returns true, if the given string matches a valid UUID (version 4, variant 2).
func NormalizePath ¶
NormalizePath replaces a leading ~ with $HOME, and removes any .. or . path elements.
func PasswordHash ¶
PasswordHash returns base64-encoded one-way hash of the provided salt and password that is computationally hard to crack by iterating through possible passwords.
func RandomPassword ¶
RandomPassword generates a random base64-encoded password.
func ReadYaml ¶
ReadYaml unmarshals the yaml contained in the file at path into obj. See goyaml.Unmarshal.
func ShQuote ¶
ShQuote quotes s so that when read by bash, no metacharacters within s will be interpreted as such.
func Timeit ¶
func Timeit(action string) func()
Start a timer, used for tracking time spent. Generally used with either defer, as in:
defer utils.Timeit("my func")()
Which will track how much time is spent in your function. Or if you want to track the time spent in a function you are calling then you would use:
toc := utils.Timeit("anotherFunc()") anotherFunc() toc()
This tracks nested calls by indenting the output, and will print out the full stack of timing when we reach the top of the stack.
Types ¶
type AttemptStrategy ¶
type AttemptStrategy struct { Total time.Duration // total duration of attempt. Delay time.Duration // interval between each try in the burst. }
AttemptStrategy represents a strategy for waiting for an action to complete successfully.
func (AttemptStrategy) Start ¶
func (a AttemptStrategy) Start() *Attempt
Start begins a new sequence of attempts for the given strategy.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
On-disk mutex protecting a resource A lock is represented on disk by a directory of a particular name, containing an information file.
|
On-disk mutex protecting a resource A lock is represented on disk by a directory of a particular name, containing an information file. |