up
This commit is contained in:
@@ -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
@@ -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,11 +46,15 @@ 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.
|
||||||
func generateSecret() string {
|
func generateSecret() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user