Provide CacheDir function
herzrasen opened this issue · 2 comments
It would be great if you could provide a function func CacheDir(appname string) (string, error)
that (in contrast to CacheFile
) only creates the cache dir for appname
.
What do you think?
Hi @herzrasen. Thank you for your interest in the library.
Creating a CacheDir
function would not be problem at all. However, I'm not sure it's completely necessary as creating a cache application directory is already a one-liner, by using xdg.CacheHome
as a base path.
os.MkdirAll(filepath.Join(xdg.CacheHome, "appDir"), os.ModeDir|0700)
EDIT: What's your use case for this? xdg.CacheFile
already creates all parent directories of the specified file anyway.
I just re-thought my use case and figured that I indeed could use xdg.CacheFile
. The use case I thought of was just to create an application specific cache directory on application startup and create the files I want to store directly. But it is perfectly reasonable to use xdg.CacheFile
. Thanks for the hint.