utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPathify

func AbsPathify(inPath string) string

AbsPathify ...

func ExitOnErrorWithMessage

func ExitOnErrorWithMessage(exitcode ExitCode.Enum, msg string) error

ExitOnErrorWithMessage informs cli to exit with message and error code

func ExitOnInvalidArgument

func ExitOnInvalidArgument() error

ExitOnInvalidArgument ...

func ExitOnInvalidOption

func ExitOnInvalidOption(msg string) error

ExitOnInvalidOption ...

func ExitOnRPC

func ExitOnRPC(msg string) error

ExitOnRPC ...

func ExtractRetCode

func ExtractRetCode(err error) (string, int, error)

ExtractRetCode extracts info from the error

func GeneratePassword

func GeneratePassword(length uint8) (string, error)

GeneratePassword generates a password with length at least 12

func LazyRemove

func LazyRemove(path string) error

LazyRemove is identical to os.Remove, but doesn't raise an error, and log.Warn every error except "file not found" which is ignored

func Plural

func Plural(value int) string

Plural returns 's' if value > 1, "" otherwise

func TitleFirst

func TitleFirst(value string) string

TitleFirst makes the first letter of the first word uppercased

func UserConfirmed

func UserConfirmed(msg string) bool

UserConfirmed asks user to confirm

Types

type Cache

type Cache interface {
	SetBy(string, func() (interface{}, error)) error
	Set(string, interface{}) error
	ForceSetBy(string, func() (interface{}, error)) error
	ForceSet(string, interface{}) error
	Reset(string) Cache
	Get(string) (interface{}, bool)
	GetOrDefault(string, interface{}) interface{}
}

Cache is an interface for caching elements

func NewMapCache

func NewMapCache() Cache

NewMapCache ...

type MapCache

type MapCache struct {
	// contains filtered or unexported fields
}

MapCache implements Cache interface using map

func (*MapCache) ForceSet

func (c *MapCache) ForceSet(key string, value interface{}) error

ForceSet ...

func (*MapCache) ForceSetBy

func (c *MapCache) ForceSetBy(key string, by func() (interface{}, error)) error

ForceSetBy ...

func (*MapCache) Get

func (c *MapCache) Get(key string) (value interface{}, ok bool)

Get ...

func (*MapCache) GetOrDefault

func (c *MapCache) GetOrDefault(key string, def interface{}) (value interface{})

GetOrDefault ...

func (*MapCache) Reset

func (c *MapCache) Reset(key string) Cache

Reset ...

func (*MapCache) Set

func (c *MapCache) Set(key string, value interface{}) error

Set ...

func (*MapCache) SetBy

func (c *MapCache) SetBy(key string, by func() (interface{}, error)) error

SetBy ...

type MyFormatter

type MyFormatter struct {
	logrus.TextFormatter
}

MyFormatter ...

func (*MyFormatter) Format

func (f *MyFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format ...

Directories

Path Synopsis
enums

Jump to

Keyboard shortcuts

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