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

@@ -42,11 +42,11 @@ func (e *ETAEstimator) GetETA() time.Duration {
if e.itemsComplete == 0 || e.totalItems == 0 {
return 0
}
elapsed := e.GetElapsed()
avgTimePerItem := elapsed / time.Duration(e.itemsComplete)
remainingItems := e.totalItems - e.itemsComplete
return avgTimePerItem * time.Duration(remainingItems)
}
@@ -83,12 +83,12 @@ func (e *ETAEstimator) GetFullStatus(baseMessage string) string {
// No items to track, just show elapsed
return fmt.Sprintf("%s | Elapsed: %s", baseMessage, e.FormatElapsed())
}
if e.itemsComplete == 0 {
// Just started
return fmt.Sprintf("%s | 0/%d | Starting...", baseMessage, e.totalItems)
}
// Full status with progress and ETA
return fmt.Sprintf("%s | %s | Elapsed: %s | ETA: %s",
baseMessage,
@@ -102,44 +102,44 @@ func FormatDuration(d time.Duration) string {
if d < time.Second {
return "< 1s"
}
hours := int(d.Hours())
minutes := int(d.Minutes()) % 60
seconds := int(d.Seconds()) % 60
if hours > 0 {
if minutes > 0 {
return fmt.Sprintf("%dh %dm", hours, minutes)
}
return fmt.Sprintf("%dh", hours)
}
if minutes > 0 {
if seconds > 5 { // Only show seconds if > 5
return fmt.Sprintf("%dm %ds", minutes, seconds)
}
return fmt.Sprintf("%dm", minutes)
}
return fmt.Sprintf("%ds", seconds)
}
// EstimateSizeBasedDuration estimates duration based on size (fallback when no progress tracking)
func EstimateSizeBasedDuration(sizeBytes int64, cores int) time.Duration {
sizeMB := float64(sizeBytes) / (1024 * 1024)
// Base estimate: ~100MB per minute on average hardware
baseMinutes := sizeMB / 100.0
// Adjust for CPU cores (more cores = faster, but not linear)
// Use square root to represent diminishing returns
if cores > 1 {
speedup := 1.0 + (0.3 * (float64(cores) - 1)) // 30% improvement per core
baseMinutes = baseMinutes / speedup
}
// Add 20% buffer for safety
baseMinutes = baseMinutes * 1.2
return time.Duration(baseMinutes * float64(time.Minute))
}