add convenience function
@@ -26,6 +26,12 @@ func IsDirectory(path string) bool {
return !errors.Is(err, os.ErrNotExist) && info.IsDir()
}
+// Returns true is the given path points to an existing file
+func IsRegularFile(path string) bool {
+ info, err := os.Stat(path)
+ return !errors.Is(err, os.ErrNotExist) && info.Mode().IsRegular()
+}
+
// Returns the content of a reader as a string
func ReaderToString(reader io.Reader) string {
var buffer strings.Builder
