diff --git a/micro/microfunctions.go b/micro/microfunctions.go index 2617f7bf..60548b90 100644 --- a/micro/microfunctions.go +++ b/micro/microfunctions.go @@ -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 +} diff --git a/micro/microfunctions_test.go b/micro/microfunctions_test.go index a526c642..140baa77 100644 --- a/micro/microfunctions_test.go +++ b/micro/microfunctions_test.go @@ -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) +}