Initial commit

This commit is contained in:
2025-05-11 20:32:14 +08:00
commit d97247159f
80 changed files with 13013 additions and 0 deletions

26
server/utils/storage.go Normal file
View File

@@ -0,0 +1,26 @@
package utils
import (
"os"
"runtime"
)
var path string
func GetStoragePath() string {
if path != "" {
return path
}
if runtime.GOOS == "linux" {
path = "/var/lib/nysoure"
} else {
userDir, _ := os.UserHomeDir()
path = userDir + "/.nysoure"
}
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
panic("failed to create storage directory")
}
}
return path
}