Initial commit
This commit is contained in:
29
internal/config/configpath_linux.go
Normal file
29
internal/config/configpath_linux.go
Normal file
@@ -0,0 +1,29 @@
|
||||
//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",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user