- 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
30 lines
644 B
Go
Executable File
30 lines
644 B
Go
Executable File
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])
|
|
}
|