diff options
| author | Jeff Carr <[email protected]> | 2025-10-21 11:51:52 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-21 11:51:52 -0500 |
| commit | 25a911f0f764e35a800eb9423acef964f4c83028 (patch) | |
| tree | 5b5bb47f813b5b676c010b61ed32b35fb43dcbbf /common.go | |
| parent | c1600cff482abf314bf66bcf758979969672bfca (diff) | |
housecleaning
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/common.go b/common.go new file mode 100644 index 0000000..d9ef0ce --- /dev/null +++ b/common.go @@ -0,0 +1,36 @@ +package config + +import ( + "os" + "runtime" + "strings" + "sync" +) + +// todo: move these somewhere else + +// a simple function name shortcut +func Exists(filename string) bool { + _, err := os.Stat(Path(filename)) + if os.IsNotExist(err) { + return false + } + return true +} + +// simple function name shortcut +func IsDir(dirname string) bool { + info, err := os.Stat(Path(dirname)) + if os.IsNotExist(err) { + return false + } + return info.IsDir() +} + +// notsure if this is a thing anymore. don't care much either +func Path(filename string) string { + if runtime.GOOS == "windows" { + filename = strings.Replace(filename, "/", "\\", -1) + } + return filename +} |
