common

package
v0.0.0-...-2f10389 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteArrayToString

func ByteArrayToString(b []byte) string

ByteArrayToString converts a byte array to a string

func DownloadFile

func DownloadFile(URL, destFile string) error

func FileExists

func FileExists(path string) bool

FileExists returns true if the file @ path exists

func GetObjectSlice

func GetObjectSlice(configuration *viper.Viper, key string) []map[string]interface{}

GetObjectSlice extracts a list of objects from a viper instance. there may be a better way to do this with viper but i've yet to find it (TODO: post issue?)

func IsDir

func IsDir(path string) bool

IsDir returns true if the object @ path is a dir

func IsFile

func IsFile(path string) bool

IsFile returns true if the object @ path is a file

func IsURL

func IsURL(s string) bool

func RetryUntilSuccessful

func RetryUntilSuccessful(duration time.Duration, interval time.Duration, callback func() bool) error

RetryUntilSuccessful calls callback every interval for duration until it returns true

func StringMapToString

func StringMapToString(source map[string]string) string

StringToStringMap converts a map of a: x, b: y to a string in the form of "a=x,b=y"

func StringSliceToIntSlice

func StringSliceToIntSlice(stringSlice []string) ([]int, error)

StringSliceToIntSlice converts slices of strings to slices of int. e.g. ["1", "3"] -> [1, 3]

func StringToStringMap

func StringToStringMap(source string) map[string]string

StringToStringMap converts a string in the form of a=x,b=y to a map of a: x, b: y

func StructureToMap

func StructureToMap(input interface{}) map[string]interface{}

StructureToMap converts a strcuture to a map, flattening all members

func TempFileSuffix

func TempFileSuffix(dir, suffix string) (f *os.File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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