From 87df3b82d5cfee05bb43f6cd18a4302fce3a8681 Mon Sep 17 00:00:00 2001 From: leafus Date: Sun, 29 Sep 2024 12:54:56 +0200 Subject: [PATCH] Add file not existent handling --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index c4a94e5..64047f1 100644 --- a/main.go +++ b/main.go @@ -92,6 +92,11 @@ func main() { os.Exit(1) } + if _, err := os.Stat(*filePath); os.IsNotExist(err) { + fmt.Printf("File does not exist: %s\n", *filePath) + os.Exit(1) + } + file, err := os.Open(*filePath) if err != nil { fmt.Printf("Error opening file: %s\n", err)