assist

package
v5.1.15+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 Huawei Technologies Co.,Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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 ErrCheckBucketStatus = errors.New("CheckBucketStatusError")
View Source
var ErrExecuting = errors.New("ExecutedError")
View Source
var ErrFileNotFound = errors.New("FileNotFoundError")
View Source
var ErrInitializing = errors.New("InitializingError")
View Source
var ErrInterrupted = errors.New("InterruptedError")
View Source
var ErrInvalidArgs = errors.New("InvalidArgsError")
View Source
var ErrTaskNotFound = errors.New("TaskNotFoundError")
View Source
var ErrUncompeleted = errors.New("UncompeletedError")
View Source
var ErrUnsupported = 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, writeBufferIoSize int, fsync bool) error

func Crc64File

func Crc64File(fileUrl string) (uint64, 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), abort *int32) 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 GetByteArrayFromPool

func GetByteArrayFromPool() []byte

func GetCpuNumber

func GetCpuNumber() int

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

func GetFileAccessTime

func GetFileAccessTime(fileInfo os.FileInfo) time.Time

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 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 PathListNested

func PathListNested(fileList []string) error

func PathSeparator

func PathSeparator() string

func PreprocessInput

func PreprocessInput(input string) (string, string, bool, error)

func PutByteArrayToPool

func PutByteArrayToPool(b []byte)

func QuickCreateFile

func QuickCreateFile(fileUrl string, size int64) error

func ReadContentLineByFileUrl

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

func ReadLine

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

func RenameFile

func RenameFile(oldpath, newpath string, forceOverwrite bool, writeBufferIoSize int, fsync bool) error

func Round

func Round(input float64) float64

func SanitizeInput

func SanitizeInput(input string) string

func SetCloudType

func SetCloudType(c string)

func SleepByCount

func SleepByCount(cnt int)

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 HintV2

type HintV2 struct {
	Message    string
	Interval   time.Duration
	Writers    []io.Writer
	Terminator string

	MessageFunc func() string
	// contains filtered or unexported fields
}

func (*HintV2) End

func (h *HintV2) End()

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