2019-04-04 01:28:13 +03:00
|
|
|
# golang util library #
|
2018-12-15 20:48:08 +03:00
|
|
|
|
2019-01-21 02:17:20 +03:00
|
|
|
(c) softlandia@gmail.com
|
|
|
|
|
2019-11-26 23:19:00 +03:00
|
|
|
>download: go get -u github.com/softlandia/xlib
|
2019-04-07 00:00:30 +03:00
|
|
|
>install: go install
|
2018-12-15 20:48:08 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
## functions ##
|
2019-01-21 02:17:20 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func StrContainBackSlash(s string) bool
|
|
|
|
return true if string s contain rune back slash '\'
|
2019-01-21 02:17:20 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func StrIsPrintRune(s string) bool
|
|
|
|
return true if input string contain only of printable rune
|
2019-01-21 02:17:20 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func ChangeFileExt(iFileName, newExt string) string
|
|
|
|
return file name with new extention
|
2018-12-15 20:48:08 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func FileExists(name string) bool
|
|
|
|
return true if file exist
|
2019-01-14 19:53:25 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func Max(x, y int) int
|
|
|
|
return max from int
|
2018-12-15 20:48:08 +03:00
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
func SortBytes(b []byte) []byte
|
|
|
|
return sorted slice of byte
|
2019-11-26 23:19:00 +03:00
|
|
|
|
|
|
|
func SeekFileStop(fileName, strToSearch string) (int, *bufio.Scanner, error)
|
2020-02-14 20:40:26 +03:00
|
|
|
search string in text file and return *bufio.Scanner at founded line
|
|
|
|
return number of line if string 'strToSearch' founded
|
|
|
|
return scanner on line with string 'strToSearch'. first call scanner.Text() - return this line
|
|
|
|
return (-1, nil, nil) if string 'strToSearch' not founded
|
|
|
|
return (-1, nil, nil) if string 'strToSearch' is empty
|
|
|
|
return (0, nil, err) if file not open or error occure when file reading
|
|
|
|
successfull opened file NOT CLOSED in any case!
|
|
|
|
strToSearch must contain only base ASCII rune
|
2019-04-06 23:59:01 +03:00
|
|
|
|
2019-11-26 23:19:00 +03:00
|
|
|
func FindFilesExt(fileList *[]string, path, fileNameExt string) (int, error)
|
2020-02-14 20:40:26 +03:00
|
|
|
search all files in path with 'ext' & put to slice
|
|
|
|
sample: n, err := FindFilesExt(&fl, "c:\\tmp", ".log")
|
2018-12-15 20:48:08 +03:00
|
|
|
|
2019-08-14 17:55:02 +03:00
|
|
|
## tests ##
|
|
|
|
|
2020-02-17 00:12:34 +03:00
|
|
|
coverage 94%
|
2019-08-14 17:55:02 +03:00
|
|
|
folder "test_files" contain files for testing, no remove/change/add
|