From e0977b4ac16c618cc6e8b16f9aba7020afa34857 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sun, 12 Feb 2023 13:37:20 -0800 Subject: [PATCH] misc: add Exists() --- internal/misc/misc.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/misc/misc.go b/internal/misc/misc.go index 076ddac..fa7136f 100644 --- a/internal/misc/misc.go +++ b/internal/misc/misc.go @@ -114,3 +114,11 @@ func GetKernelVersion() (string, error) { return strings.TrimSpace(string(contents)), nil } + +// Exists tests if the given file/dir exists or not +func Exists(file string) bool { + if _, err := os.Stat(file); err == nil { + return true + } + return false +}