How to check if a file exists in Go
If you need to check if a file exists using Go, then you can use one of the following methods, depending on the version of Go you may be using.
If you are using Go >=1.13, then
However, it is also possible to trap an error from an OpenFile
attempt:
You can also confirm if the path is also not a directory as follows: