utils library for golang
Перейти к файлу
sergienko.v5 5c2d08cec0 file path for unix 2023-04-17 18:16:26 +03:00
test_files v0.0.3 2019-11-27 00:06:36 +04:00
.gitignore 0.0.1 2019-08-14 18:55:02 +04:00
HIST.md v0.1.4 2021-01-23 00:11:25 +03:00
README.md v0.1.4 2021-01-23 00:11:25 +03:00
date.go file path for unix 2023-04-17 18:16:26 +03:00
go.mod file path for unix 2023-04-17 18:16:26 +03:00
go.sum file path for unix 2023-04-17 18:16:26 +03:00
linter.md v0.1.1 2020-05-19 00:25:15 +04:00
utils.go v0.1.1 2020-05-19 00:25:15 +04:00
utils_test.go file path for unix 2023-04-17 18:16:26 +03:00
xFileUtil.go fix FileExist 2020-08-17 02:43:28 +04:00
xFileUtil_test.go file path for unix 2023-04-17 18:16:26 +03:00
xStrUtil.go file path for unix 2023-04-17 18:16:26 +03:00
xStrUtil_test.go v0.1.4 2021-01-23 00:11:25 +03:00

README.md

golang util library

(c) softlandia@gmail.com

download: go get -u github.com/softlandia/xlib
install: go install

functions

func Secret(s string) string
  returns a string with the middle removed, "passport" -> "pa...rt"

func AtoI(s string, def int) int
  returns int from string, on error return def

func StrHash(s string) uint32
  returns 32bit hash from string, using fnv.New32a

func StrContainBackSlash(s string) bool
  returns true if string s contain rune back slash '\'

func StrIsPrintRune(s string) bool  
  returns true if input string contain only of printable rune

func ChangeFileExt(iFileName, newExt string) string  
  returns file name with new extention

func FileExists(name string) bool  
  returns true if file exist

func Max(x, y int) int
  returns max from int

func SortBytes(b []byte) []byte
  returns sorted slice of byte

func SeekFileStop(fileName, strToSearch string) (int, *bufio.Scanner, error)
  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

func FindFilesExt(fileList *[]string, path, fileNameExt string) (int, error)  
  search all files in path with 'ext' & put to slice
  sample:  n, err := FindFilesExt(&fl, "c:\\tmp", ".log")

tests

coverage 94%
folder "test_files" contain files for testing, no remove/change/add