Documentation ¶
Index ¶
- Variables
- func ArgsGet(index int, args []string) string
- func Cat(filename ...string) error
- func CheckErr(msg interface{})
- func Cp(sourceFile, destinationFile string) bool
- func CreateSymLink(src, dest string) error
- func DirAllChild(directory string) (files []string, err error)
- func DirCopy(srcDir, dstDir string) error
- func DirCopyKeepOwner(srcDir, dstDir string) error
- func DirCreate(dirPath string, permission fs.FileMode) error
- func DirIsEmptyorNotexist(directory string) bool
- func DirMove(src, dst string) error
- func DirMoveKeepOwner(src, dst string) error
- func DirRemove(dirPath string) error
- func DirRemoveContents(dir string) error
- func File2lines(filePath string) ([]string, error)
- func FileCloneDate(dst, src string) bool
- func FileCopy(src, dst string) (int64, error)
- func FileCopyKeepOwner(src, dst string) (int64, error)
- func FileCreate(fullPath string) error
- func FileCreateOverwrite(fullPath string) error
- func FileCreateWithContent(fullPath string, data []byte) (bytewrite int, err error)
- func FileGetSize(filepath string) (int64, error)
- func FileHashMd5(filePath string) (string, error)
- func FileInsertStringAtLine(filePath, str string, index int) error
- func FileIsWriteable(path string) (isWritable bool)
- func FileMove(src, dst string) (int64, error)
- func FileMoveSameFileSys(src, dst string) error
- func FileOpen2Write(fullPath string) (*os.File, error)
- func FileReadAll(fullPath string) (string, error)
- func FileRemoveFile(path string) error
- func FileTempCreateInNewTemDir(filename string) string
- func FileTempCreateInNewTemDirWithContent(filename string, data []byte) string
- func FileToURL(in string) string
- func FileWaitContentsAndRead(path string, timeoutms int) (string, error)
- func FileWaitForFileExist(path string, timeoutms int) error
- func FileWriteStringIfChange(pathfile string, contents []byte) (bool, error)
- func GenerateID() string
- func GenerateIdv4(preString string) (string, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func GenerateSha1Bytes(data []byte) string
- func GenerateSha1String(data string) string
- func GenerateTokenSha1(key int) string
- func GetCurrentContainerID(filepaths ...string) (id string)
- func InitLogger(filePath string, logger *log.Logger, level log.Level) error
- func InitLoggerStdout(logger *log.Logger, level log.Level)
- func Int64ToBytes(number int64) []byte
- func Int64ToString(number int64) string
- func IsContainer() bool
- func JsonGetPathNode(node *jsonquery.Node) (retstr string)
- func JsonParser(str string) gjson.Result
- func JsonParserBytes(bs []byte) gjson.Result
- func JsonSet(jsonstring string, elementPath string, val any) (string, error)
- func JsonStringFindElement(strjson *string, pathSearch string) (string, error)
- func JsonStringFindElements(strjson *string, pathSearch string, valueflag ...bool) (map[string]string, error)
- func JsonStringFindElementsSlide(strjson *string, pathSearch string) ([]string, error)
- func PATHArr() []string
- func PATHGetEnvPathValue() string
- func PATHJointList(PATH, data string) string
- func PATHRemove(PATH, addpath string) string
- func ParserShellPath(shellPath string) string
- func PathBaseName(filePath string) string
- func PathGetEnvPathKey() string
- func PathIsDir(path string) bool
- func PathIsExist(path string) bool
- func PathIsFile(path string) bool
- func Reader2lines(r io.Reader) ([]string, error)
- func SliceStringRemoveDuplicates(slice []string) []string
- func String2Int64(str string) int64
- func String2lines(str string) []string
- func StringGetFirstFields(str string, delimiter string, firstNField uint16) string
- func StringInSlice(a string, list []string) bool
- func SymWalk(path string, walkFn filepath.WalkFunc) error
- func SysGetGroupId() string
- func SysGetHomeDir() (home string)
- func SysGetUserId() string
- func SysGetUsername() string
- func TokenSha1IsMatch(key int, token string) bool
- func Touch(name string) error
- func Which(filePath, PATH string) (string, bool)
- func WindowsIsAdmin() bool
- func WriteStringAndCheck(b io.StringWriter, s string)
Constants ¶
This section is empty.
Variables ¶
var ( GOOS = runtime.GOARCH AppName string AppVersion string NEWLINE = "\n" Ipv4Regex = `([0-9]+\.){3}[0-9]+` )
Functions ¶
func CheckErr ¶
func CheckErr(msg interface{})
CheckErr prints the msg with the prefix 'Error:' and exits with error code 1. If the msg is nil, it does nothing.
func DirAllChild ¶
list all file and dir int level1 of dir
func DirCopy ¶
Copy dir, change ownner (as user execute), change datetime modify Notes: Care full with recursive can't overload the File decriptor limit
func DirCopyKeepOwner ¶
Notes: Care full with recursive can't overload the File decriptor limit
func DirIsEmptyorNotexist ¶
func DirMoveKeepOwner ¶
func File2lines ¶
func FileCloneDate ¶
cp date-time modify from dst file to src file
func FileCopyKeepOwner ¶
cp source to dir, keep modify time, owner. If dest exist, overwrite it
func FileCreateOverwrite ¶
func FileCreateWithContent ¶
func FileInsertStringAtLine ¶
insert string at index lines of file, if this line have text, push it one line down.
func FileIsWriteable ¶
func FileMoveSameFileSys ¶
func FileOpen2Write ¶
open and attend to file
func FileReadAll ¶
func FileRemoveFile ¶
removeFile removes the specified file. Errors are ignored.
func FileTempCreateInNewTemDir ¶
create tempdir and return tempfile in tempdir (not create yet)
func FileToURL ¶
return C:/path/to/file.txt on windows(fileToURL("C:\\path\\to\\file.txt")) and path/to/file.txt on Linux (fileToURL("/path/to/file.txt")).
func FileWaitContentsAndRead ¶
readFile waits for the specified file to contain contents, and then returns
those contents as a string. If an error occurs while reading the file, the error is returned. If the file has no content after 100 attempts, an error is returned.
func FileWaitForFileExist ¶
waitForFile waits for the specified file to exist before returning. If the an
error, other than the file not existing, occurs, the error is returned. If, after 100 attempts, the file does not exist, an error is returned.
func FileWriteStringIfChange ¶
write content to file if it different with exist file content
func GenerateID ¶
func GenerateID() string
func GenerateRandomString ¶
Get random string with n character
func GenerateSha1String ¶
func GenerateTokenSha1 ¶
func GetCurrentContainerID ¶
GetCurrentContainerID attempts to extract the current container ID from the provided file paths. (call inside container)
If no files paths are provided, it will default to /proc/1/cpuset, /proc/self/cgroup and /proc/self/mountinfo. It attempts to match the HOSTNAME first then use the fallback method, and returns with the first valid match.
func Int64ToBytes ¶
func Int64ToString ¶
func IsContainer ¶
func IsContainer() bool
func JsonGetPathNode ¶
func JsonParser ¶
func JsonParserBytes ¶
func JsonStringFindElement ¶
func JsonStringFindElements ¶
func PATHGetEnvPathValue ¶
func PATHGetEnvPathValue() string
func PATHJointList ¶
add data to PATH , vd: /home/mannk:path
func ParserShellPath ¶
parser shell path include ${shelvariale}
func PathIsExist ¶
func PathIsFile ¶
func String2Int64 ¶
func StringGetFirstFields ¶
get n field of string seprate by delimiter string
func StringInSlice ¶
func SysGetGroupId ¶
func SysGetGroupId() string
func SysGetHomeDir ¶
func SysGetHomeDir() (home string)
func SysGetUserId ¶
func SysGetUserId() string
func SysGetUsername ¶
func SysGetUsername() string
func TokenSha1IsMatch ¶
compare token (15s limit between create and check) (ex: http post and response confrim)
func WindowsIsAdmin ¶
func WindowsIsAdmin() bool
func WriteStringAndCheck ¶
func WriteStringAndCheck(b io.StringWriter, s string)
WriteStringAndCheck writes a string into a buffer, and checks if the error is not nil.
Types ¶
This section is empty.