utils

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2016 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const HomeDirFlag = "~"

HomeDirFlag 当前用户家目录标识符

Variables

View Source
var (
	FgYellow = color.New(color.FgYellow).SprintFunc()
	FgBlue   = color.New(color.FgBlue).SprintFunc()
	FgRed    = color.New(color.FgRed).SprintFunc()
	FgCyan   = color.New(color.FgCyan).SprintFunc()
	FgGreen  = color.New(color.FgGreen).SprintFunc()

	FgBoldYellow = color.New(color.FgYellow, color.Bold).SprintFunc()
	FgBoldBlue   = color.New(color.FgBlue, color.Bold).SprintFunc()
	FgBoldRed    = color.New(color.FgRed, color.Bold).SprintFunc()
	FgBoldCyan   = color.New(color.FgCyan, color.Bold).SprintFunc()
	FgBoldGreen  = color.New(color.FgGreen, color.Bold).SprintFunc()

	BgYellow = color.New(color.BgYellow).SprintFunc()
	BgBlue   = color.New(color.BgBlue).SprintFunc()
	BgRed    = color.New(color.BgRed).SprintFunc()
	BgCyan   = color.New(color.BgCyan).SprintFunc()
	BgGreen  = color.New(color.BgGreen).SprintFunc()

	BgBoldYellow = color.New(color.BgYellow, color.Bold).SprintFunc()
	BgBoldBlue   = color.New(color.BgBlue, color.Bold).SprintFunc()
	BgBoldRed    = color.New(color.BgRed, color.Bold).SprintFunc()
	BgBoldCyan   = color.New(color.BgCyan, color.Bold).SprintFunc()
	BgBoldGreen  = color.New(color.BgGreen, color.Bold).SprintFunc()
)
View Source
var (
	// ErrFileExisted error message when file exist
	ErrFileExisted = "target file %s is existed"
	// ErrMd5Check error message when check md5
	ErrMd5Check = "md5 is not same: Origin MD5(%s)\tCurrent MD5(%s)"
)
View Source
var ErrUploadFile = "upload file failed: URL(%s)\nfilename(%s)\nmessage(%s)"

ErrUploadFile error message when upload file failed

Functions

func ChkMd5Info

func ChkMd5Info(filepath string, md5Str string) error

ChkMd5Info check md5 info is same or not

func Confirm

func Confirm(promptStr string) bool

Confirm 标准输入确认

func ConvertHomeDir

func ConvertHomeDir(raw string) (string, error)

ConvertHomeDir convert ~ to user's home dir

func DirExist

func DirExist(dirpath string) bool

DirExist 判断文件夹是否存在

func ExecLinuxCmd

func ExecLinuxCmd(cmdStr string) ([]byte, error)

ExecLinuxCmd 执行脚本

func FileExist

func FileExist(filepath string) bool

FileExist 判断文件是否存在

func IsDir

func IsDir(filepath string) bool

IsDir is directory or not

func IsWildCharMatch

func IsWildCharMatch(s string, wildCharStrs ...string) bool

IsWildCharMatch check s is match one of wildCharStrs or not

func LocalPathSize added in v0.6.5

func LocalPathSize(dirPath string) (int64, error)

LocalPathSize directory size with all file in it

func LoginNo

func LoginNo(promptStr string, min, max int) int

LoginNo which node you want to login [min, max)

func Md5File

func Md5File(filepath string) (string, error)

Md5File generate md5 string

func NewProgressBar added in v0.6.5

func NewProgressBar(prefix string, count int64) *pb.ProgressBar

func PostFile

func PostFile(fileParam, filePath string, extraParams map[string]string, targetURL string) error

PostFile post file to targetUrl

func TarGz

func TarGz(src string, dstTgz string, ow bool) error

TarGz 压缩

func Trim

func Trim(s string, cutsets ...string) string

Trim reomve leading and trailing cutsets of s

func UnTarGz

func UnTarGz(srcTarGz string, dstDir string) error

UnTarGz 解压

func WildCharToRegexp

func WildCharToRegexp(s string) string

WildCharToRegexp change string with wildchar to regexp format string

Types

This section is empty.

Jump to

Keyboard shortcuts

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