From 8048a2e9c5773235122027dd585cf821b2af1249 Mon Sep 17 00:00:00 2001 From: shirou Date: Wed, 1 Aug 2018 14:39:43 +0900 Subject: [PATCH] [disk] add an comment. --- disk/disk_unix.go | 2 ++ 1 file changed, 2 insertions(+) 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 }