This commit is contained in:
2026-06-21 18:35:12 +08:00
parent 67023378ce
commit 4f6c24cc49
2 changed files with 12 additions and 4 deletions
+1
View File
@@ -5,6 +5,7 @@ main.exe
# Auto-generated runtime data (config + database + uploads) # Auto-generated runtime data (config + database + uploads)
win/ win/
mac/
# IDE # IDE
.vscode/ .vscode/
+11 -4
View File
@@ -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. // getConfigPath returns the OS-aware config directory and config file path.
func getConfigPath() (dir, file string) { func getConfigPath() (dir, file string) {
if runtime.GOOS == "windows" { switch runtime.GOOS {
case "windows":
dir = filepath.Join(".", "win", "etc", "blog_go") dir = filepath.Join(".", "win", "etc", "blog_go")
} else { case "darwin":
dir = filepath.Join(".", "mac", "etc", "blog_go")
default:
dir = filepath.Join("/", "etc", "blog_go") dir = filepath.Join("/", "etc", "blog_go")
} }
file = filepath.Join(dir, "config.yaml") file = filepath.Join(dir, "config.yaml")
@@ -43,10 +46,14 @@ func getConfigPath() (dir, file string) {
// getDefaultStoragePath returns the OS-aware default storage path. // getDefaultStoragePath returns the OS-aware default storage path.
func getDefaultStoragePath() string { func getDefaultStoragePath() string {
if runtime.GOOS == "windows" { switch runtime.GOOS {
case "windows":
return filepath.Join(".", "win", "srv", "blog_go") 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. // generateSecret returns a random-ish hex string for the session secret.