From a06e3362be691331215b10bdefc28a2db363563a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 18 Mar 2022 22:23:16 -0400 Subject: datadir/datadir.go: add CacheDir() --- datadir/datadir.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'datadir') 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) +} -- cgit v1.2.3