utils

package
v0.0.0-...-5f8f03c Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chown

func Chown(f, usr string) (err error)

func Copy

func Copy(src, dest string) error

func CreateParentDir

func CreateParentDir(f string) error

func DownloadFromUrl

func DownloadFromUrl(url, localFile string, overWrite bool) (int, error)

return retry times and error

func DownloadViaWget

func DownloadViaWget(url, localFile string, overWrite bool) error

func FQDN

func FQDN() string

Get Fully Qualified Domain Name returns "unknown" or hostanme in case of error

func InStringSlice

func InStringSlice(s []string, e string) (exist bool)

s should be sorted

func IsFileExist

func IsFileExist(fpath string) bool

func IsSameFileContent

func IsSameFileContent(f1, f2 string) (bool, error)

func Md5sum

func Md5sum(file string) (string, error)

func MoreCopy

func MoreCopy(src, dest string, convertFn CopyConvertFn) error

func RandStr

func RandStr(l int) string

func RecursiveFindFiles

func RecursiveFindFiles(root string, pattern string) ([]string, error)

recursiveFindFiles find files with pattern in the root with depth.

func Retry

func Retry(attemptFunc RetriableFunc, maxTries int, sleep time.Duration) (int, error)

Retry will call attemptFunc up to maxTries until it returns nil, sleeping the specified amount of time between each call. The function can return an error to abort the retrying, or return RetriableError to allow the function to be called again. Returns tried times without running successfully

func SafeCreate

func SafeCreate(f string) (file *os.File, err error)

func SleepMS

func SleepMS(ms int)

func Split

func Split(s, sep string) []string

func Tree

func Tree(dir string) (o []byte, err error)

Types

type CopyConvertFn

type CopyConvertFn func(in []byte) (out []byte, err error)

type RetriableError

type RetriableError struct {
	Failure error
}

RetriableError can be returned by any function called with Retry(), to indicate that it should be retried again after a sleep interval.

func (RetriableError) Error

func (retriable RetriableError) Error() string

type RetriableFunc

type RetriableFunc func() error

Jump to

Keyboard shortcuts

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