1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-23 22:45:11 +02:00

сделал ReadFile_Linux_Windows()

This commit is contained in:
Sanek
2025-07-07 09:34:38 +03:00
parent 1772a7bf52
commit 89c9bd94f1
2 changed files with 20 additions and 0 deletions

View File

@@ -2076,3 +2076,14 @@ func FindPos(Text string, MassFind ...string) int {
return Otvet
}
// ReadFile_Linux_Windows - читаем файл и удаляет "\r"
func ReadFile_Linux_Windows(Filename string) ([]byte, error) {
MassBytes, err := os.ReadFile(Filename)
if err == nil {
MassBytes = bytes.ReplaceAll(MassBytes, []byte("\r"), []byte(""))
}
return MassBytes, err
}

View File

@@ -1843,3 +1843,12 @@ func TestFindPos(t *testing.T) {
t.Error("TestFindPos() error")
}
}
func TestReadFile_Linux_Windows(t *testing.T) {
dir := ProgramDir()
MassBytes, err := ReadFile_Linux_Windows(dir + ".env_empty")
if err != nil {
t.Error("ReadFile_Linux_Windows() error: ", err)
}
fmt.Print(MassBytes)
}