util

package
v0.0.0-...-fd72eb8 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2015 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvDefault

func EnvDefault(key, fallback string) string

EnvDefault returns the value of the given environment variable key if it is not empty. If it is empty it returns the fallback as an absolute path joined with the users home.

func Escape

func Escape(name string) (escaped string, err error)

Escape escapes the given data to make sure it is safe to use it as a filename. It also replaces spaces and other seperation characters with the '-' character. It returns an error if the escaped string is empty.

func Get

func Get(uri string) (resp *http.Response, err error)

Get performs a HTTP GET request, just like http.get, however, it has a few handy extra features: I adds a User-Agent header and it retries a failed get request if the error was a temporary one.

func GetFile

func GetFile(uri, target string) (fp string, err error)

GetFile downloads the file from the given uri and stores it in the specified target directory. If a download was interrupted previously GetFile is able to resume it.

func Lock

func Lock(path string) (err error)

Lock creates a lockfile at the given path and creates a signal handler which removes the lockfile on interrupt or kill.

func Username

func Username() string

Username returns the username of the current user. It tries to determine the username using os/user first and if that doesn't work it returns the value of the USER environment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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