Skip to content

Commit adfee58

Browse files
committed
extract helper for readability
1 parent d053c36 commit adfee58

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fstat/fstat.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ func (fs FilesystemStat) Total() uint64 {
2424
// HasReachedLimit returns true if the used disk space is greater than or equal
2525
// to the given limit in percent.
2626
func (fs FilesystemStat) HasReachedLimit(limit uint64) bool {
27-
used := uint64((float64(fs.Used()) / float64(fs.Total())) * 100)
28-
return used >= limit
27+
return fs.usedPercentage() >= limit
28+
}
29+
30+
func (fs FilesystemStat) usedPercentage() uint64 {
31+
return uint64((float64(fs.Used()) / float64(fs.Total())) * 100)
2932
}
3033

3134
func GetFilesystemStat(path string) (FilesystemStat, error) {

0 commit comments

Comments
 (0)