mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-24 22:53:52 +02:00
сделал ReadFile_Linux_Windows()
This commit is contained in:
@@ -2076,3 +2076,14 @@ func FindPos(Text string, MassFind ...string) int {
|
|||||||
|
|
||||||
return Otvet
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1843,3 +1843,12 @@ func TestFindPos(t *testing.T) {
|
|||||||
t.Error("TestFindPos() error")
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user