up
This commit is contained in:
+4
-3
@@ -87,12 +87,13 @@ func defaultConfig() *Config {
|
|||||||
// configPath 返回当前平台的配置文件路径
|
// configPath 返回当前平台的配置文件路径
|
||||||
func configPath() string {
|
func configPath() string {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
// Windows: 相对于可执行文件的 conf/config.toml
|
// Windows: 相对于工作目录的 conf/config.toml
|
||||||
exePath, err := os.Executable()
|
// 注意: 使用工作目录而非 os.Executable(),因为 go run 时 exe 在临时目录
|
||||||
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "conf/config.toml"
|
return "conf/config.toml"
|
||||||
}
|
}
|
||||||
return filepath.Join(filepath.Dir(exePath), "conf", "config.toml")
|
return filepath.Join(wd, "conf", "config.toml")
|
||||||
}
|
}
|
||||||
// Linux: FHS 标准 /etc/portal_page/config.toml
|
// Linux: FHS 标准 /etc/portal_page/config.toml
|
||||||
return "/etc/portal_page/config.toml"
|
return "/etc/portal_page/config.toml"
|
||||||
|
|||||||
Reference in New Issue
Block a user