Documentation
¶
Index ¶
- Variables
- func AlignLinux(input ...[]string) [][]string
- func AlignPrintWithColon(s ...string) string
- func CalculatePartSize(size int64) (partSize int64, err error)
- func CheckConfirm(msg string) (bool, error)
- func DoubleCheckString(expect, msg string) (bool, error)
- func IsQsPath(s string) bool
- func NewQingStorService() (storage.Servicer, error)
- func NewQingStorStorage(pairs ...*typ.Pair) (storage.Storager, error)
- func ParseAtServiceInput(t interface{ ... }) (err error)
- func ParseAtStorageInput(t interface{ ... }, input string) (dstWorkDir string, err error)
- func ParseBetweenStorageInput(t interface{ ... }, src, dst string) (srcWorkDir, dstWorkDir string, err error)
- func ParseByteSize(s string) (int64, error)
- func ParseFlow(src, dst string) (flow constants.FlowType)
- func ParseFsWorkDir(path string) (wd, file string, err error)
- func ParseLocalPath(p string) (pathType typ.ObjectType, err error)
- func ParseQsPath(p string) (keyType typ.ObjectType, bucketName, objectKey string, err error)
- func ParseQsWorkDir(path string) (wd, file string)
- func ParseServiceInput(serviceType StoragerType) (service storage.Servicer, err error)
- func ParseStorageInput(input string, storageType StoragerType) (workDir, path string, objectType typ.ObjectType, store storage.Storager, ...)
- func UnixReadableSize(hrSize string) (string, error)
- type ConfirmCheck
- type ConfirmChecker
- type InputCheck
- type StoragerType
- type StrDoubleChecker
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFlow = errors.New("invalid flow")
ErrInvalidFlow returned when parsed flow not valid
var ErrReadableSizeFormat = errors.New("readable size format invalid")
ErrReadableSizeFormat will return when size format not the same with expected.
var ErrStoragerTypeInvalid = errors.New("storager type no valid")
ErrStoragerTypeInvalid returned when storager type invalid
Functions ¶
func AlignLinux ¶
AlignLinux will align print by lines (element in slice)
func AlignPrintWithColon ¶
AlignPrintWithColon will align print with ":"
func CalculatePartSize ¶
CalculatePartSize will calculate the object's part size.
func CheckConfirm ¶
CheckConfirm is the public func for confirm check
func DoubleCheckString ¶
DoubleCheckString is the public func for string double check
func NewQingStorService ¶
func NewQingStorService() (storage.Servicer, error)
NewQingStorService will create a new qingstor service.
func NewQingStorStorage ¶
NewQingStorStorage will create a new qingstor storage.
func ParseAtServiceInput ¶
func ParseAtServiceInput(t interface { types.ServiceSetter }) (err error)
ParseAtServiceInput will parse single args and setup service.
func ParseAtStorageInput ¶
func ParseAtStorageInput(t interface { types.PathSetter types.StorageSetter types.TypeSetter }, input string) (dstWorkDir string, err error)
ParseAtStorageInput will parse single args and setup path, type, storager.
func ParseBetweenStorageInput ¶
func ParseBetweenStorageInput(t interface { types.SourcePathSetter types.SourceStorageSetter types.SourceTypeSetter types.DestinationPathSetter types.DestinationStorageSetter types.DestinationTypeSetter }, src, dst string) (srcWorkDir, dstWorkDir string, err error)
ParseBetweenStorageInput will parse two args into flow, path and key.
func ParseByteSize ¶
ParseByteSize will tried to parse string to byte size.
func ParseFsWorkDir ¶
ParseFsWorkDir get a path as input, split the work dir and file by following rules 1. if the path is like /path/to/target, parse the wd as /path/to/ and file as target; 2. if the path is like /path/to/, parse the wd as /path/to/ and file as ""; 3. if the path is like . , parse the wd as {pwd}/ and file as "". ParseFsWorkDir use os.PathSeparator as the separator, for capability of windows.
Example ¶
var wd, file string wd, file, _ = ParseFsWorkDir("/path/to/file") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) wd, file, _ = ParseFsWorkDir("/path/to/") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) wd, file, _ = ParseFsWorkDir("/") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) // wd, file, _ = ParseWorkDir(".") // fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) // Will get --> wd: <{pwd}/>, file: <> // wd, file, _ = ParseWorkDir("-") // fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) // Will get --> wd: <{pwd}/>, file: <->
Output: wd: </path/to/>, file: <file> wd: </path/to/>, file: <> wd: </>, file: <>
func ParseLocalPath ¶
func ParseLocalPath(p string) (pathType typ.ObjectType, err error)
ParseLocalPath will parse a path into different path type.
func ParseQsPath ¶
func ParseQsPath(p string) (keyType typ.ObjectType, bucketName, objectKey string, err error)
ParseQsPath will parse a key into different key type.
func ParseQsWorkDir ¶
ParseQsWorkDir get a path as input, split the work dir and file by like ParseFsWorkDir What's difference is ParseQsWorkDir use '/' as separator, which is defined by qingstor service.
Example ¶
var wd, file string wd, file = ParseQsWorkDir("/path/to/file") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) wd, file = ParseQsWorkDir("/path/to/") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file)) wd, file = ParseQsWorkDir("/") fmt.Println(fmt.Sprintf("wd: <%s>, file: <%s>", wd, file))
Output: wd: </path/to/>, file: <file> wd: </path/to/>, file: <> wd: </>, file: <>
func ParseServiceInput ¶
func ParseServiceInput(serviceType StoragerType) (service storage.Servicer, err error)
ParseServiceInput will parse service input.
func ParseStorageInput ¶
func ParseStorageInput(input string, storageType StoragerType) ( workDir, path string, objectType typ.ObjectType, store storage.Storager, err error)
ParseStorageInput will parse storage input and return a initiated storager.
func UnixReadableSize ¶
UnixReadableSize will transfer readable size string into Unix size. 1 KB --> 1B, 1.2 GB --> 1.2G, 103 B --> 103B
Types ¶
type ConfirmCheck ¶
type ConfirmCheck struct {
// contains filtered or unexported fields
}
ConfirmCheck implements ConfirmChecker
func (ConfirmCheck) CheckConfirm ¶
func (c ConfirmCheck) CheckConfirm() (bool, error)
CheckConfirm implements ConfirmChecker.CheckConfirm
type ConfirmChecker ¶
ConfirmChecker try to confirm return confirmed or not
type InputCheck ¶
type InputCheck struct {
// contains filtered or unexported fields
}
InputCheck implements StrDoubleChecker
func (InputCheck) DoubleCheckString ¶
func (s InputCheck) DoubleCheckString() (bool, error)
DoubleCheckString implements StrDoubleChecker.DoubleCheckString()
type StrDoubleChecker ¶
StrDoubleChecker double check a string and return satisfied or not