diff --git a/cmd/server/main.go b/cmd/server/main.go index 0a54262..bdf0141 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -32,8 +32,7 @@ import ( "github.com/gin-gonic/gin" "go.uber.org/zap" - - _ "carrotskin/docs" // Swagger docs + // _ "carrotskin/docs" // Swagger docs ) func main() { diff --git a/pkg/config/config.go b/pkg/config/config.go index 48fba01..630aff4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -131,7 +131,11 @@ type SecurityConfig struct { // Load 加载配置 - 完全从环境变量加载,不依赖YAML文件 func Load() (*Config, error) { // 加载.env文件(如果存在) - _ = godotenv.Load(".env") + if err := godotenv.Load(".env"); err != nil { + fmt.Printf("[Config] 注意: 未加载 .env 文件 (原因: %v)\n", err) + } else { + fmt.Println("[Config] 成功加载 .env 文件") + } // 设置默认值 setDefaults() @@ -152,6 +156,20 @@ func Load() (*Config, error) { // 从环境变量中覆盖配置 overrideFromEnv(&config) + // 打印关键配置加载状态 + fmt.Println("==================================================") + fmt.Println(" CarrotSkin Configuration Check ") + fmt.Println("==================================================") + fmt.Printf("Server Port: %s\n", config.Server.Port) + fmt.Printf("Database Host: %s\n", config.Database.Host) + fmt.Printf("Redis Host: %s\n", config.Redis.Host) + fmt.Printf("Environment: %s\n", config.Environment) + + if config.Database.Host == "localhost" && os.Getenv("DATABASE_HOST") != "" && os.Getenv("DATABASE_HOST") != "localhost" { + fmt.Printf("[Warning] Database Host is 'localhost' but env DATABASE_HOST is set to '%s'. Viper binding might have failed.\n", os.Getenv("DATABASE_HOST")) + } + fmt.Println("==================================================") + return &config, nil } diff --git a/pkg/storage/minio_test.go b/pkg/storage/minio_test.go index 6f3c32d..7d29c3a 100644 --- a/pkg/storage/minio_test.go +++ b/pkg/storage/minio_test.go @@ -1,9 +1,9 @@ package storage import ( - "context" + // "context" "testing" - "time" + // "time" "carrotskin/pkg/config"