ci cross-platform fix: make system_info disk usage helper windows-safe with build tags

This commit is contained in:
DBT
2026-03-01 13:04:58 +00:00
parent 618a8a3723
commit 09a28836ca
3 changed files with 31 additions and 10 deletions

View File

@@ -0,0 +1,22 @@
//go:build !windows
package tools
import "fmt"
import "syscall"
func diskUsageRoot() string {
var stat syscall.Statfs_t
if err := syscall.Statfs("/", &stat); err != nil {
return ""
}
bsize := uint64(stat.Bsize)
total := stat.Blocks * bsize
free := stat.Bfree * bsize
used := total - free
if total == 0 {
return ""
}
return fmt.Sprintf("Disk (/): Used %.2f GB / Total %.2f GB (%.2f%%)\n",
float64(used)/1024/1024/1024, float64(total)/1024/1024/1024, float64(used)/float64(total)*100)
}