From 4f6c24cc49bb9f1834fe7452ba8fc0ea1a65de4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E9=97=BB=E9=A3=8E?= Date: Sun, 21 Jun 2026 18:35:12 +0800 Subject: [PATCH] up --- .gitignore | 1 + config/config.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4f03090..d1e240a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ main.exe # Auto-generated runtime data (config + database + uploads) win/ +mac/ # IDE .vscode/ diff --git a/config/config.go b/config/config.go index bf58e16..308763f 100644 --- a/config/config.go +++ b/config/config.go @@ -32,9 +32,12 @@ const mysqlExampleDSN = "user:password@tcp(127.0.0.1:3306)/blog_go?charset=utf8m // getConfigPath returns the OS-aware config directory and config file path. func getConfigPath() (dir, file string) { - if runtime.GOOS == "windows" { + switch runtime.GOOS { + case "windows": dir = filepath.Join(".", "win", "etc", "blog_go") - } else { + case "darwin": + dir = filepath.Join(".", "mac", "etc", "blog_go") + default: dir = filepath.Join("/", "etc", "blog_go") } file = filepath.Join(dir, "config.yaml") @@ -43,10 +46,14 @@ func getConfigPath() (dir, file string) { // getDefaultStoragePath returns the OS-aware default storage path. func getDefaultStoragePath() string { - if runtime.GOOS == "windows" { + switch runtime.GOOS { + case "windows": return filepath.Join(".", "win", "srv", "blog_go") + case "darwin": + return filepath.Join(".", "mac", "srv", "blog_go") + default: + return filepath.Join("/", "srv", "blog_go") } - return filepath.Join("/", "srv", "blog_go") } // generateSecret returns a random-ish hex string for the session secret.