assist

package
v5.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OBS_PREFIX        = "obs://"
	COMMAND_CONNECTOR = "-"
	OBS_PREFIX_LEN    = 6
)
View Source
const (
	KB = 1024
	MB = KB * 1024
	GB = MB * 1024
	TB = GB * 1024

	K   = 1000
	MLN = K * K
	BLN = K * K * K
)

Variables

View Source
var CheckBucketStatusError = errors.New("CheckBucketStatusError")
View Source
var ExecutingError = errors.New("ExecutedError")
View Source
var FileNotFoundError = errors.New("FileNotFoundError")
View Source
var InitializingError = errors.New("InitializingError")
View Source
var InterruptedError = errors.New("InterruptedError")
View Source
var InvalidArgsError = errors.New("InvalidArgsError")
View Source
var TaskNotFoundError = errors.New("TaskNotFoundError")
View Source
var UncompeletedError = errors.New("UncompeletedError")
View Source
var UnsupportedError = errors.New("UnsupportedError")

Functions

func AdaptWildcards

func AdaptWildcards(input string) string

func Base64Decode

func Base64Decode(value string) ([]byte, error)

func Base64Encode

func Base64Encode(value []byte) string

func Base64Md5

func Base64Md5(value []byte) string

func BytesToString

func BytesToString(b []byte) string

func CheckErrorAndExit

func CheckErrorAndExit(err error)

func Chown

func Chown(path string) error

func CompileWildcardInput

func CompileWildcardInput(input string) (*regexp.Regexp, error)

func CopyFile

func CopyFile(oldpath, newpath string, checkNewpathLength bool) error

func DoCompress

func DoCompress(file *os.File, prefix string, zw *zip.Writer) (int64, error)

func EnsureDirectory

func EnsureDirectory(dir string) (err error)

func EnterBashMode

func EnterBashMode(additionalTips func(), callback func(value string))

func FindDirsToDelete

func FindDirsToDelete(dir string) (dirs []string, err error)

func FindFiles

func FindFiles(folder string, pattern *regexp.Regexp, action func(fileUrl string)) error

func FindFilesV2

func FindFilesV2(folder string, pattern *regexp.Regexp) ([]string, error)

func FindMatches

func FindMatches(fileUrl string, pattern *regexp.Regexp, action func(groups []string)) error

func FormatUtcNow

func FormatUtcNow(format string) string

func FormatUtcToRfc1123

func FormatUtcToRfc1123(t time.Time) string

func GetArch

func GetArch() string

func GetBase64Md5

func GetBase64Md5(writer io.Writer) string

func GetCpuNumber

func GetCpuNumber() int

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

func GetHexMd5

func GetHexMd5(writer io.Writer) string

func GetMd5Writer

func GetMd5Writer() io.Writer

func GetOS

func GetOS() string

func GetOsPath

func GetOsPath(path string) (ret string)

func GetRealPath

func GetRealPath(path string) (realPath string, realStat os.FileInfo, err error)

func GetTerminalWidth

func GetTerminalWidth() (int, error)

func GetUtcNow

func GetUtcNow() time.Time

func HasChinese

func HasChinese(val string) bool

func HasCommandPrex

func HasCommandPrex(commandArg string) bool

func HasUnicode

func HasUnicode(val string) bool

func Hex

func Hex(value []byte) string

func HexMd5

func HexMd5(value []byte) string

func HmacSha1

func HmacSha1(key, value []byte) []byte

func HmacSha256

func HmacSha256(key, value []byte) []byte

func Home

func Home() (string, error)

func Int64ToString

func Int64ToString(value int64) string

func IntToString

func IntToString(value int) string

func IsDt

func IsDt() bool

func IsHec

func IsHec() bool

func IsLinux

func IsLinux() bool

func IsMac

func IsMac() bool

func IsObsFilePath

func IsObsFilePath(path string) bool

func IsOtc

func IsOtc() bool

func IsWindows

func IsWindows() bool

func MaxFloat64

func MaxFloat64(va, vb float64) float64

func MaxInt

func MaxInt(va, vb int) int

func MaybeAddTrailingSlash

func MaybeAddTrailingSlash(srckey string) string

func MaybeDeleteBeginningSlash

func MaybeDeleteBeginningSlash(srckey string) string

func MaybeDeleteTrailingSlash

func MaybeDeleteTrailingSlash(srckey string) string

func Md5

func Md5(value []byte) []byte

func Md5File

func Md5File(fileUrl string) ([]byte, error)

func MinFloat64

func MinFloat64(va, vb float64) float64

func MinInt

func MinInt(va, vb int) int

func MkdirAll

func MkdirAll(path string, perm os.FileMode) error

func NormalizeBytes

func NormalizeBytes(size int64) string

func NormalizeCount

func NormalizeCount(count int64, unit string) string

func NormalizeFilePath

func NormalizeFilePath(fileUrl string) string

func NormalizeFileSize

func NormalizeFileSize(fileUrl string) string

func OpenFile

func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)

func ParseXml

func ParseXml(value []byte, result interface{}) error

func ReadContentLineByFileUrl

func ReadContentLineByFileUrl(fileUrl string) ([]string, error)

func ReadLine

func ReadLine(rd *bufio.Reader) ([]byte, error)

func Rename

func Rename(oldpath, newpath string) error

func RenameFile

func RenameFile(oldpath, newpath string) error

func Round

func Round(val float64) (newVal float64)

func SanitizeInput

func SanitizeInput(input string) string

func SetCloudType

func SetCloudType(c string)

func Str2Timestamp

func Str2Timestamp(str string, defaultValue int64) (ts int64, err error)

func StringToBytes

func StringToBytes(s string) []byte

func StringToFloat64

func StringToFloat64(value string, def float64) float64

func StringToFloat64V2

func StringToFloat64V2(value string) (float64, error)

func StringToInt

func StringToInt(value string, def int) int

func StringToInt64

func StringToInt64(value string, def int64) int64

func StringToInt64V2

func StringToInt64V2(value string) (int64, error)

func StringToIntV2

func StringToIntV2(value string) (int, error)

func TransToXml

func TransToXml(value interface{}) ([]byte, error)

func TranslateToFloat64

func TranslateToFloat64(value string) (float64, error)

func TranslateToInt64

func TranslateToInt64(value string) (int64, error)

func UseDefaultDownloadPath

func UseDefaultDownloadPath(args []string) bool

func Wrap

func Wrap(reader io.Reader, writers ...io.Writer) io.Reader

Types

type Hint

type Hint struct {
	Message    string
	Interval   time.Duration
	Writers    []io.Writer
	Terminator string
	// contains filtered or unexported fields
}

func NewHint

func NewHint(message string, interval time.Duration) *Hint

func (*Hint) End

func (h *Hint) End()

func (*Hint) Start

func (h *Hint) Start(writers ...io.Writer)

type HintV2

type HintV2 struct {
	Hint
	MessageFunc func() string
	// contains filtered or unexported fields
}

func (*HintV2) Start

func (h *HintV2) Start(writers ...io.Writer)

type MapHelper

type MapHelper map[string]string

func (MapHelper) Get

func (m MapHelper) Get(key string) string

type MultiWritersReader

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

func (*MultiWritersReader) Read

func (mwr *MultiWritersReader) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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