添加歌曲封面接口
All checks were successful
Go CI / test-and-build (push) Successful in 12s

This commit is contained in:
2026-04-06 23:16:34 +08:00
parent 3182b29932
commit 0b7cd05486
5 changed files with 63 additions and 1 deletions

View File

@@ -3,22 +3,32 @@ package config
import (
"log"
"os"
"path"
"strconv"
)
type Config struct {
DatabasePath string
CachePath string
}
// LoadConfig loads configuration from environment variables
func LoadConfig() *Config {
cfg := &Config{
DatabasePath: getEnv("DATABASE_PATH", "./butterfliu.db"),
CachePath: getEnv("CACHE_PATH", "./cache"),
}
os.MkdirAll(cfg.CachePath, os.ModeAppend)
return cfg
}
func (self *Config) GetCachePath(cacheType string) string {
path := path.Join(self.CachePath, cacheType)
os.MkdirAll(path, os.ModeAppend)
return path
}
// getEnv gets an environment variable with a default value
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {