Add file not existent handling
This commit is contained in:
parent
e72a7a7468
commit
87df3b82d5
5
main.go
5
main.go
|
@ -92,6 +92,11 @@ func main() {
|
||||||
os.Exit(1)
|
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)
|
file, err := os.Open(*filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error opening file: %s\n", err)
|
fmt.Printf("Error opening file: %s\n", err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user