aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--datadir/datadir.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/datadir/datadir.go b/datadir/datadir.go
index 9019e5d..583dac4 100644
--- a/datadir/datadir.go
+++ b/datadir/datadir.go
@@ -46,3 +46,16 @@ func Join(args ...string) (string, error) {
return filepath.Join(dir, filepath.Join(args...)), nil
}
}
+
+// Get path to cache directory path within data directory and create it
+// if it does not exist.
+func CacheDir() (string, error) {
+ // build path, check for error
+ dir, err := Join("cache")
+ if err != nil {
+ return "", err
+ }
+
+ // create and return cache directory
+ return dir, os.MkdirAll(dir, 0700)
+}