utils

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: Apache-2.0 Imports: 20 Imported by: 5

Documentation

Index

Constants

View Source
const (
	PERM_WRITE = iota
	PERM_READ
	PERM_EXE
	PERM_WRITE_READ
	PERM_WRITE_EXE
	PERM_READ_EXE
	PERM_READ_WRITE_EXE

	TYPE_REGULAR = iota
	TYPE_DIR
	TYPE_SYMLINK
	TYPE_PIPE
	TYPE_SOCKET
	TYPE_OTHER
)

Variables

View Source
var (
	FOLDER_MODE = 0755
)

Functions

func AddConPath

func AddConPath(base string, in string) string

func AddVartoFile

func AddVartoFile(env string, file string) *Error

func ChangeFilePermssion

func ChangeFilePermssion(file string, perm uint32) (bool, *Error)

func CheckCompleteness

func CheckCompleteness(folder string, checklist []string) *Error

func CheckFilePermission

func CheckFilePermission(file string, perm uint32, force bool) (bool, *Error)

func CheckProcessByPid

func CheckProcessByPid(pid string) (bool, *Error)

func CompareVersion

func CompareVersion(str1, str2, delimeter string) (int, *Error)

func ConvertTar2Gzip

func ConvertTar2Gzip(src_file, target_file string) *Error

convert tar to tar.gz

func CopyFile

func CopyFile(src string, dst string) (bool, *Error)

func CopyMap

func CopyMap(m map[string]interface{}) map[string]interface{}

func CreateTempDir

func CreateTempDir(dir string) (string, *Error)

this function is used for the replacement of system ioutil.TempDir, as sometimes the /tmp folder is another mount on HPC and rename could not be done

func DownloadFile

func DownloadFile(url string, folder string, filename string) *Error

func FileExist

func FileExist(file string) bool

func FilePermission

func FilePermission(file interface{}, permType int8) (bool, *Error)

only check user permission

func FileType

func FileType(file string) (int8, *Error)

func FindStringArray added in v1.9.0

func FindStringArray(s string, arr []string) (int, bool)

func FolderExist

func FolderExist(folder string) bool

func GetConfigDir

func GetConfigDir() (string, *Error)

func GetCurrDir

func GetCurrDir() (string, *Error)

func GetFileLength

func GetFileLength(file string) (int64, *Error)

func GetFilePermission

func GetFilePermission(file interface{}) (uint32, *Error)

func GetFileSize

func GetFileSize(file interface{}) (int64, *Error)
func GetGDriveDownloadLink(url string) (string, *Error)

func GetHostOSInfo

func GetHostOSInfo() (string, string, *Error)

func GetProcessIdByName

func GetProcessIdByName(name string) (bool, string, *Error)

func GuessPath

func GuessPath(base string, in string, file bool) (string, *Error)

func GuessPathContainer

func GuessPathContainer(base string, layers []string, in string, file bool) (string, *Error)

func GuessPathsContainer

func GuessPathsContainer(base string, layers []string, in string, file bool) ([]string, *Error)

get all existed paths rather than only one

func IsNumeric

func IsNumeric(s string) bool

func KillProcessByPid

func KillProcessByPid(pid string) *Error

func MakeDir

func MakeDir(dir string) (bool, *Error)

func RandomPort

func RandomPort(min, max int) int

func RandomString

func RandomString(n int) string

func ReadFromFile

func ReadFromFile(dir string) ([]byte, *Error)

func RegularFileExist added in v1.6.2

func RegularFileExist(file string) bool

func RemoveAll

func RemoveAll(dir string) (bool, *Error)

func RemoveFile

func RemoveFile(path string) (bool, *Error)

func Rename

func Rename(old_path string, new_path string) *Error

func ReverseStrArray

func ReverseStrArray(input []string) []string

func Sha256file

func Sha256file(file string) (string, *Error)

func Sha256str

func Sha256str(str string) (string, *Error)

func TarFiles

func TarFiles(filelist []string, target_folder string, target_name string) *Error

func TarLayer

func TarLayer(src_folder string, target_folder string, target_name string, layers []string) *Error

this tar function eliminate symlink

func Untar

func Untar(file string, folder string) *Error

func UntarLayer

func UntarLayer(file string, folder string) *Error

func WalkandCheckFilePermission

func WalkandCheckFilePermission(folder string, checklist []string, perm uint32, force bool) (bool, *Error)

func WriteToFile

func WriteToFile(data []byte, dir string) *Error

Types

This section is empty.

Jump to

Keyboard shortcuts

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