utils

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile from src to dst

func DockerVersion

func DockerVersion(host string, port string) (string, error)

DockerVersion docker verion

func Download

func Download(filepath string, url string) (err error)

Download a resource from URL to given path

func EnsureFile

func EnsureFile(fullpath string) error

EnsureFile ensure a file

func EnsurerDir

func EnsurerDir(dir string) (err error)

EnsurerDir Create Dir if not exist

func GetCurrentExecPath

func GetCurrentExecPath() (scriptPath string)

GetCurrentExecPath parses a path from running executable/go file

func GetHostIP

func GetHostIP() (net.IP, error)

GetHostIP returns the host's IP

func GetLangFromFileName

func GetLangFromFileName(fileName string) (lang string)

GetLangFromFileName get programming language from file name extension

func IsPathExists

func IsPathExists(path string) (bool, error)

IsPathExists checks whether a path exists or if failed to check

func OutputJSON

func OutputJSON(v interface{}) error

OutputJSON output json

func PairsToParams

func PairsToParams(pairs []string) map[string]string

PairsToParams make "a=1, b=2" to be {"a": "1", "b": "2"}

func RunWithRetry

func RunWithRetry(f func() error, interval time.Duration, maxRetries int) (err error)

RunWithRetry run a closure and retry for times when it fails

func TarDir

func TarDir(dir string, tarFileName string) error

TarDir make tar of a dir

func Unzip

func Unzip(source string, target string) (err error)

Unzip a folder to destination

Types

This section is empty.

Jump to

Keyboard shortcuts

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