Documentation
¶
Overview ¶
Package diskspace reports free and total bytes of the filesystem holding a path, on Unix and Windows, and formats byte counts for display.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Free ¶
Free reports the bytes free at path that an unprivileged user could write, per statfs's Bavail field (not Bfree, which includes root-reserved blocks).
func HumanBytes ¶
HumanBytes renders bytes the same way web/src/lib/format.ts's own formatBytes does (binary units, one decimal place under 10 of a unit, none at or above), so a value read from Free and one read from the dashboard's own API response read the same regardless of which side rendered it. Negative bytes render as "0 B" rather than a negative unit, since this only ever wraps a real filesystem free-space value.
Example ¶
package main
import (
"fmt"
"github.com/GLINCKER/levelrail/kit/diskspace"
)
func main() {
fmt.Println(diskspace.HumanBytes(1536))
fmt.Println(diskspace.HumanBytes(5 << 30))
}
Output: 1.5 KiB 5.0 GiB
Types ¶
This section is empty.