mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-25 07:49:19 -04:00
Merged config and app packages into one called caddy. Abstracted away caddy startup functionality making it easier to embed Caddy in any Go application and use it as a library. Graceful restart (should) now ensure child starts properly. Now piping a gob bundle to child process so that the child can match up inherited listeners to server address. Much cleanup still to do.
30 lines
616 B
Go
30 lines
616 B
Go
package assets
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
// Path returns the path to the folder
|
|
// where the application may store data. This
|
|
// currently resolves to ~/.caddy
|
|
func Path() string {
|
|
return filepath.Join(userHomeDir(), ".caddy")
|
|
}
|
|
|
|
// userHomeDir returns the user's home directory according to
|
|
// environment variables.
|
|
//
|
|
// Credit: http://stackoverflow.com/a/7922977/1048862
|
|
func userHomeDir() string {
|
|
if runtime.GOOS == "windows" {
|
|
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
|
|
if home == "" {
|
|
home = os.Getenv("USERPROFILE")
|
|
}
|
|
return home
|
|
}
|
|
return os.Getenv("HOME")
|
|
}
|