30 lines
572 B
Go
30 lines
572 B
Go
//go:build linux
|
|
|
|
// @tag config
|
|
// @tag platform:linux
|
|
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// DefaultConfigPaths returns the config file search paths for Linux.
|
|
// Root user: only /etc/pekoe/config.json
|
|
// Regular user: ~/.pekoe.json, then /etc/pekoe/config.json
|
|
func DefaultConfigPaths() []string {
|
|
if os.Getuid() == 0 {
|
|
return []string{"/etc/pekoe/config.json"}
|
|
}
|
|
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return []string{"/etc/pekoe/config.json"}
|
|
}
|
|
|
|
return []string{
|
|
filepath.Join(home, ".pekoe.json"),
|
|
"/etc/pekoe/config.json",
|
|
}
|
|
}
|