diff --git a/disk/disk_unix.go b/disk/disk_unix.go index f1f1cf7..9b499b5 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -50,6 +50,8 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { if (ret.Used + ret.Free) == 0 { ret.UsedPercent = 0 } else { + // We don't use ret.Total to calculate percent. + // see https://github.com/shirou/gopsutil/issues/562 ret.UsedPercent = (float64(ret.Used) / float64(ret.Used+ret.Free)) * 100.0 }