From 3a0cfb29665c1721de34b65e4fb434677b7ed149 Mon Sep 17 00:00:00 2001 From: Marco Kittel Date: Sun, 29 Jun 2025 11:18:04 +0200 Subject: [PATCH] =?UTF-8?q?Error=20Message=20in=20ScanCsv=20hinzugef=C3=BC?= =?UTF-8?q?gt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eliofile/eliofile.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eliofile/eliofile.go b/eliofile/eliofile.go index 8f5bf0c..9cf099c 100644 --- a/eliofile/eliofile.go +++ b/eliofile/eliofile.go @@ -47,15 +47,14 @@ func NewElioDateiFoo(lookUpDir string, process ElioHandleFunc) *ElioDateiFoo { // Warenhausnamen in eine eine Hashmap ablegen. Dopplungen mit dem spätesten Zeitpunkt behalten. // Veraltete Dateien mit Präfix no-import und Postifx .old benennen. // Gültige Dateinamen zur Extraktion in Closure übergeben. -func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) { +func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) error { files, err := os.ReadDir(f.lookUpDir) if err != nil { - fmt.Println(err) + return err } filemap := make(map[string]filedata) for _, file := range files { - fmt.Printf("Lese Datei: %s\n", file) if !strings.Contains(file.Name(), FileExt) { continue } @@ -71,7 +70,7 @@ func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) if tl.Unix() >= value.dt.Unix() { err := os.Rename(f.lookUpDir+"/"+value.filename, f.lookUpDir+"/"+"no-import-"+value.filename+".old") if err != nil { - fmt.Printf("Datei %s konnte nicht umbenannt werden!!!", value.filename) + return fmt.Errorf("Datei %s konnte nicht umbenannt werden!!!", value.filename) } filemap[warehouse] = filedata{filename: file.Name(), dt: tl} } @@ -91,4 +90,5 @@ func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) f.mu.Unlock() f.process(ctx, v.filename, data) } + return nil }