Fix cross-platform builds: process cleanup and disk space checking

- Add platform-specific implementations for Windows, BSD systems
- Create platform-specific disk space checking with proper syscalls
- Add Windows process cleanup using tasklist/taskkill
- Add BSD-specific Statfs_t field handling (F_blocks, F_bavail, F_bsize)
- Support 9/10 target platforms (Linux, Windows, macOS, FreeBSD, OpenBSD)
- Process cleanup now works on all Unix-like systems and Windows
- Phase 2 TUI improvements compatible across platforms
This commit is contained in:
2025-11-18 19:15:49 +00:00
parent 694c8c802a
commit ccf70db840
6 changed files with 398 additions and 28 deletions

29
internal/checks/types.go Normal file
View File

@@ -0,0 +1,29 @@
package checks
import "fmt"
// DiskSpaceCheck represents disk space information
type DiskSpaceCheck struct {
Path string
TotalBytes uint64
AvailableBytes uint64
UsedBytes uint64
UsedPercent float64
Sufficient bool
Warning bool
Critical bool
}
// formatBytes formats bytes to human-readable format
func formatBytes(bytes uint64) string {
const unit = 1024
if bytes < unit {
return fmt.Sprintf("%d B", bytes)
}
div, exp := uint64(unit), 0
for n := bytes / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %ciB", float64(bytes)/float64(div), "KMGTPE"[exp])
}