ci: add golangci-lint config and fix formatting

- Add .golangci.yml with minimal linters (govet, ineffassign)
- Run gofmt -s and goimports on all files to fix formatting
- Disable fieldalignment and copylocks checks in govet
This commit is contained in:
2025-12-11 17:53:28 +01:00
parent 6b66ae5429
commit 914307ac8f
89 changed files with 1516 additions and 1618 deletions

View File

@@ -14,18 +14,18 @@ import (
func runStatus(ctx context.Context) error {
// Update config from environment
cfg.UpdateFromEnvironment()
// Validate configuration
if err := cfg.Validate(); err != nil {
return fmt.Errorf("configuration error: %w", err)
}
// Display header
displayHeader()
// Display configuration
displayConfiguration()
// Test database connection
return testConnection(ctx)
}
@@ -41,7 +41,7 @@ func displayHeader() {
fmt.Println("\033[1;37m Database Backup & Recovery Tool\033[0m")
fmt.Println("\033[1;34m==============================================================\033[0m")
}
fmt.Printf("Version: %s (built: %s, commit: %s)\n", cfg.Version, cfg.BuildTime, cfg.GitCommit)
fmt.Println()
}
@@ -53,32 +53,32 @@ func displayConfiguration() {
fmt.Printf(" Host: %s:%d\n", cfg.Host, cfg.Port)
fmt.Printf(" User: %s\n", cfg.User)
fmt.Printf(" Database: %s\n", cfg.Database)
if cfg.Password != "" {
fmt.Printf(" Password: ****** (set)\n")
} else {
fmt.Printf(" Password: (not set)\n")
}
fmt.Printf(" SSL Mode: %s\n", cfg.SSLMode)
if cfg.Insecure {
fmt.Printf(" SSL: disabled\n")
}
fmt.Printf(" Backup Dir: %s\n", cfg.BackupDir)
fmt.Printf(" Compression: %d\n", cfg.CompressionLevel)
fmt.Printf(" Jobs: %d\n", cfg.Jobs)
fmt.Printf(" Dump Jobs: %d\n", cfg.DumpJobs)
fmt.Printf(" Max Cores: %d\n", cfg.MaxCores)
fmt.Printf(" Auto Detect: %v\n", cfg.AutoDetectCores)
// System information
fmt.Println()
fmt.Println("System Information:")
fmt.Printf(" OS: %s/%s\n", runtime.GOOS, runtime.GOARCH)
fmt.Printf(" CPU Cores: %d\n", runtime.NumCPU())
fmt.Printf(" Go Version: %s\n", runtime.Version())
// Check if backup directory exists
if info, err := os.Stat(cfg.BackupDir); err != nil {
fmt.Printf(" Backup Dir: %s (does not exist - will be created)\n", cfg.BackupDir)
@@ -87,7 +87,7 @@ func displayConfiguration() {
} else {
fmt.Printf(" Backup Dir: %s (exists but not a directory!)\n", cfg.BackupDir)
}
fmt.Println()
}
@@ -95,7 +95,7 @@ func displayConfiguration() {
func testConnection(ctx context.Context) error {
// Create progress indicator
indicator := progress.NewIndicator(true, "spinner")
// Create database instance
db, err := database.New(cfg, log)
if err != nil {
@@ -103,7 +103,7 @@ func testConnection(ctx context.Context) error {
return err
}
defer db.Close()
// Test tool availability
indicator.Start("Checking required tools...")
if err := db.ValidateBackupTools(); err != nil {
@@ -111,7 +111,7 @@ func testConnection(ctx context.Context) error {
return err
}
indicator.Complete("Required tools available")
// Test connection
indicator.Start(fmt.Sprintf("Connecting to %s...", cfg.DatabaseType))
if err := db.Connect(ctx); err != nil {
@@ -119,32 +119,32 @@ func testConnection(ctx context.Context) error {
return err
}
indicator.Complete("Connected successfully")
// Test basic operations
indicator.Start("Testing database operations...")
// Get version
version, err := db.GetVersion(ctx)
if err != nil {
indicator.Fail(fmt.Sprintf("Failed to get database version: %v", err))
return err
}
// List databases
databases, err := db.ListDatabases(ctx)
if err != nil {
indicator.Fail(fmt.Sprintf("Failed to list databases: %v", err))
return err
}
indicator.Complete("Database operations successful")
// Display results
fmt.Println("Connection Test Results:")
fmt.Printf(" Status: Connected ✅\n")
fmt.Printf(" Version: %s\n", version)
fmt.Printf(" Databases: %d found\n", len(databases))
if len(databases) > 0 {
fmt.Printf(" Database List: ")
if len(databases) <= 5 {
@@ -165,9 +165,9 @@ func testConnection(ctx context.Context) error {
}
fmt.Println()
}
fmt.Println()
fmt.Println("✅ Status check completed successfully!")
return nil
}
}