utils

package
v2.0.0-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableCache bool

DisableCache will disable caching of the home directory. Caching is enabled by default.

Functions

func CheckError

func CheckError(fn func() error)

CheckError will execute the func, handle it's panic and error

func CreateFile

func CreateFile(p string) (f *os.File, err error)

CreateFile will create a file recursively.

func Dir

func Dir() (string, error)

Dir returns the home directory for the executing user.

This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func Expand

func Expand(path string) (string, error)

Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.

func FromTaskContext

func FromTaskContext(ctx context.Context) string

FromTaskContext will extract task name from context.

func FromTxContext

func FromTxContext(ctx context.Context) *db.Tx

FromTxContext will extract tx from context.

func NewTaskContext

func NewTaskContext(ctx context.Context, t string) context.Context

NewTaskContext will create a ctx with task name.

func NewTxContext

func NewTxContext(ctx context.Context, tx *db.Tx) context.Context

NewTxContext will create a ctx with tx.

Types

type ContextKey

type ContextKey string

ContextKey is the type for context key.

const (
	ContextKeyTx   ContextKey = "tx"
	ContextKeyTask ContextKey = "task"
)

Context keys.

Jump to

Keyboard shortcuts

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