From 89c9bd94f149cc161cf59bf68ee4cfbbd881fd3c Mon Sep 17 00:00:00 2001 From: Sanek Date: Mon, 7 Jul 2025 09:34:38 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20ReadFile?= =?UTF-8?q?=5FLinux=5FWindows()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- micro/microfunctions.go | 11 +++++++++++ micro/microfunctions_test.go | 9 +++++++++ 2 files changed, 20 insertions(+) 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) +}