This commit is contained in:
softlandia 2020-05-19 00:25:15 +04:00
Родитель ff6823436a
Коммит d3af3a5579
5 изменённых файлов: 41 добавлений и 4 удалений

Просмотреть файл

@ -1,5 +1,11 @@
# VERTION DESCRIPTION #
## ver 0.1.1 // 2020.05.19 ##
* add StrHash()
_____________________________
## ver 0.1.0 // 2020.02.16 ##
* using assert for testing

15
linter.md Normal file
Просмотреть файл

@ -0,0 +1,15 @@
xFileUtil_test.go:37:2: ineffectual assignment to `index` (ineffassign)
index, scanner, err := SeekFileStop("test_files\\866&1251.txt", "~A")
^
xFileUtil_test.go:42:18: ineffectual assignment to `err` (ineffassign)
index, scanner, err = SeekFileStop("test_files\\866&1251.txt", "")
^
xFileUtil_test.go:45:18: ineffectual assignment to `err` (ineffassign)
index, scanner, err = SeekFileStop("test_files\\empty_file.txt", "~")
^
xFileUtil_test.go:69:5: ineffectual assignment to `err` (ineffassign)
n, err := FindFilesExt(&fl, ".", ".txt")
^
xFileUtil_test.go:48:9: SA4006: this value of `scanner` is never used (staticcheck)
index, scanner, err = SeekFileStop("test_files\\rune_error_1251.txt", "#")
^

Просмотреть файл

@ -1,6 +1,9 @@
package xlib
import "sort"
import (
"hash/fnv"
"sort"
)
//Epsilon - precission
const Epsilon float64 = 0.01
@ -18,3 +21,10 @@ func SortBytes(b []byte) []byte {
sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
return b
}
// StrHash - make hash from string
func StrHash(s string) uint32 {
h := fnv.New32a()
h.Write([]byte(s))
return h.Sum32()
}

Просмотреть файл

@ -41,9 +41,15 @@ func ReadFileStop(fileName, strStop string) (string, error) {
return sb.String(), iScanner.Err()
}
// TextScanner -
type TextScanner struct {
scanner *bufio.Scanner
file *os.File
}
//SeekFileStop - 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 scanner on line with string 'strToSearch'. 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

Просмотреть файл

@ -90,8 +90,8 @@ func ReplaceSeparators(s string) string {
{". ", "."},
{" :", ":"},
{": ", ":"},
{":.", ":"},
{".:", "."},
//{":.", ":"},
//{".:", "."},
}
for _, sep := range SeparatorsList {
s = strings.ReplaceAll(s, sep.old, sep.new)