common

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppMode bool

Functions

func ByteSize

func ByteSize(bytes uint64) string

func Chmod

func Chmod(path string, mod os.FileMode)

Chmod changes mod of a path

func CreateFile

func CreateFile(path string, size int64)

CreateFile creates an empty file with given length (if size > 0)

func CreateFolder

func CreateFolder(path string)

CreateFolder creates folder on local drive

func Elapsed

func Elapsed(s string, start time.Time)

Elapsed gets time elapsed

func Exit

func Exit()

Exit exits the program with non-zero status code

func Finish

func Finish()

Finish exits the program with zero status code

func FromByteSize

func FromByteSize(s string) string

FromByteSize converts size string in bytes into uinit, e.g., 1024 into 1K

func GenTempFileName

func GenTempFileName(parts ...string) string

GenTempFileName generate /tmp/%x files where %x is md5 value of all parts concate together

func GetDstPath

func GetDstPath(srcPrefix, srcPath, dstPrefix string) string

GetDstPath gets the destination path

func GetFileCRC32C

func GetFileCRC32C(path string) uint32

GetFileCRC32C gets the crc32c of a file

func GetFileMD5

func GetFileMD5(path string) []byte

GetFileMD5 gets the md5 of a file

func GetFileModificationTime

func GetFileModificationTime(path string) time.Time

GetFileModificationTime gets mtime of a file

func GetFileSize

func GetFileSize(path string) int64

GetFileSize gets the size of a file

func GetRelativePath

func GetRelativePath(dir, path string) string

GetRelativePath gets the relative path given path and directory

func GetTempFile

func GetTempFile(path string) string

GetTempFile gets a temp file name

func GetWorkDir

func GetWorkDir() string

GetWorkDir returns the directory where the executable file put

func IsPathDirectory

func IsPathDirectory(path string) bool

IsPathDirectory determines if a path is a directory

func IsPathExist

func IsPathExist(path string) bool

IsPathExist determines if a path exists

func IsPathFile

func IsPathFile(path string) bool

IsPathFile determines if a path is a file

func IsSubPath

func IsSubPath(subPath, path string) bool

IsSubPath checks if a path is under another one in directory manner case 1: gs://abc/def -> gs://abc/def : true case 2: gs://abc/def -> gs://abc/de : false case 3: gs://abc/def -> gs://abc/def/ : false case 4: gs://abc/def/-> gs://abc/def/ : true case 5: gs://abc/def/ghi -> gs://abc/def : true case 6: gs://abc/def/ghi -> gs://abc/de : false case 7: gs://abc/def/ghi -> gs://abc/def/ : true

func IsTempFile

func IsTempFile(path string) bool

IsTempFile checks if a file is temp file

func JoinPath

func JoinPath(dir string, parts ...string) string

JoinPath combines dir and parts into a new path

func ParseFile

func ParseFile(input string) (string, string)

ParseFile parses file into dir, name

func ParseObjectUrl added in v1.0.12

func ParseObjectUrl(url string) (scheme, bucket, prefix string, err error)

func ParseURL

func ParseURL(input string) (string, string, string)

ParseURL parses url into scheme, bucket, prefix

func Recovery

func Recovery()

Recovery recovers from exceptions

func SetFileModificationTime

func SetFileModificationTime(path string, mt time.Time)

SetFileModificationTime sets mtime to a file

func SetPrefixAsDirectory

func SetPrefixAsDirectory(prefix string) string

SetPrefixAsDirectory sets the prefix as directory

Types

This section is empty.

Jump to

Keyboard shortcuts

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