From bf86ab9c8376d22657a2e20c56d50ba2b6f2b273 Mon Sep 17 00:00:00 2001 From: Marco Kittel Date: Sat, 28 Jun 2025 17:51:52 +0200 Subject: [PATCH] Csv Extension in Konstante ausgelagert. --- eliofile/eliofile.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eliofile/eliofile.go b/eliofile/eliofile.go index 5b58961..9dc9ab1 100644 --- a/eliofile/eliofile.go +++ b/eliofile/eliofile.go @@ -10,6 +10,8 @@ import ( "gittea.marcokittel.de/elio/eliotools/tools" ) +const FileExt = "csv" + type filedata struct { filename string dt time.Time @@ -17,12 +19,13 @@ type filedata struct { type ElioHandleFunc func(filename string) bool type ElioDateiFoo struct { - process ElioHandleFunc - dir string + process ElioHandleFunc + lookUpDir string + processedDir string } -func NewElioDateiFoo(dir string, process ElioHandleFunc) *ElioDateiFoo { - df := ElioDateiFoo{dir: dir, +func NewElioDateiFoo(lookUpDir string, process ElioHandleFunc) *ElioDateiFoo { + df := ElioDateiFoo{lookUpDir: lookUpDir, process: process, } return &df @@ -34,7 +37,7 @@ func NewElioDateiFoo(dir string, process ElioHandleFunc) *ElioDateiFoo { // Veraltete Dateien mit Präfix no-import und Postifx .old benennen. // Gültige Dateinamen zur Extraktion in Closure übergeben. func (f *ElioDateiFoo) ScanCsv() { - files, err := os.ReadDir(f.dir) + files, err := os.ReadDir(f.lookUpDir) if err != nil { log.Fatal(err) @@ -42,7 +45,7 @@ func (f *ElioDateiFoo) ScanCsv() { filemap := make(map[string]filedata) for _, file := range files { - if !strings.Contains(file.Name(), "csv") { + if !strings.Contains(file.Name(), FileExt) { continue } tl, err := tools.ExtractDateAndConvertToDate(file.Name())