From 43baeb5ae6862451b35373cf468ed19f913ff0fb Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Sat, 5 Aug 2023 15:09:19 +0200
Subject: [PATCH] refactor: Refactor import statements and add error handling
 to check directory existence

- Remove unused import statement for "golang.org/x/exp/slices"
- Add necessary import statement for "golang.org/x/exp/slices"
- Implement error handling code to check directory existence
---
 file.go | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/file.go b/file.go
index 633ac37..297efb2 100644
--- a/file.go
+++ b/file.go
@@ -4,11 +4,12 @@
 package configuration
 
 import (
-	"golang.org/x/exp/slices"
 	"io/fs"
 	"os"
 	"path"
 	"path/filepath"
+
+	"golang.org/x/exp/slices"
 )
 
 type files struct {
@@ -137,10 +138,12 @@ func (s *Settings[C]) sanitizeDirectories() {
 			visited[d] = true
 		}
 
-		if _, err := os.Stat(d); os.IsNotExist(err) {
-			s.errors = append(s.errors, newPathDoesNotExistError(d))
-		}
+	}
 
+	// check last entry
+	d := s.files.directories[len(s.files.directories)-1]
+	if _, err := os.Stat(d); os.IsNotExist(err) {
+		s.errors = append(s.errors, newPathDoesNotExistError(d))
 	}
 
 }
-- 
GitLab