MCPcopy
hub / github.com/caddyserver/caddy / AppConfigDir

Function AppConfigDir

storage.go:86–101  ·  view source on GitHub ↗

AppConfigDir returns the directory where to store user's config. If XDG_CONFIG_HOME is set, it returns: $XDG_CONFIG_HOME/caddy. Otherwise, os.UserConfigDir() is used; if successful, it appends "Caddy" (Windows & Mac) or "caddy" (every other OS) to the path. If it returns an error, the fallback path

()

Source from the content-addressed store, hash-verified

84//
85// Ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
86func AppConfigDir() string {
87 if basedir := os.Getenv("XDG_CONFIG_HOME"); basedir != "" {
88 return filepath.Join(basedir, "caddy")
89 }
90 basedir, err := os.UserConfigDir()
91 if err != nil {
92 Log().Warn("unable to determine directory for user configuration; falling back to current directory", zap.Error(err))
93 return "./caddy"
94 }
95 subdir := "caddy"
96 switch runtime.GOOS {
97 case "windows", "darwin":
98 subdir = "Caddy"
99 }
100 return filepath.Join(basedir, subdir)
101}
102
103// AppDataDir returns a directory path that is suitable for storing
104// application data on disk. It uses the environment for finding the

Callers 1

storage.goFile · 0.85

Calls 2

LogFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected