summaryrefslogtreecommitdiffhomepage
path: root/storage.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-12-31 18:31:43 -0700
committerMatthew Holt <[email protected]>2019-12-31 18:31:43 -0700
commit06ea0a52950ef6d1dd327c10e247ada1b71a5c5d (patch)
tree0c369a5410adb561c88dd3df7e1f921addda041e /storage.go
parent788462bd4c9c332b3f892094b1d17147378f5e6a (diff)
downloadcaddy-06ea0a52950ef6d1dd327c10e247ada1b71a5c5d.tar.gz
caddy-06ea0a52950ef6d1dd327c10e247ada1b71a5c5d.zip
Tune AppConfigDir and docs for Storage module
Diffstat (limited to 'storage.go')
-rw-r--r--storage.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/storage.go b/storage.go
index b7dcfe44f..03f769176 100644
--- a/storage.go
+++ b/storage.go
@@ -84,14 +84,13 @@ func homeDirUnsafe() string {
//
// Ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
func AppConfigDir() string {
- basedir := os.Getenv("XDG_CONFIG_HOME")
- if basedir == "" {
- var err error
- basedir, err = os.UserConfigDir()
- if err != nil {
- Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
- return "./caddy"
- }
+ if basedir := os.Getenv("XDG_CONFIG_HOME"); basedir != "" {
+ return filepath.Join(basedir, "caddy")
+ }
+ basedir, err := os.UserConfigDir()
+ if err != nil {
+ Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
+ return "./caddy"
}
subdir := "caddy"
switch runtime.GOOS {