/usr/share/gocode/src/github.com/cloudfoundry/gosigar/examples/df.go is in golang-github-cloudfoundry-gosigar-dev 0.0~git20150402.27.3ed7c74-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // Copyright (c) 2012 VMware, Inc.
package main
import (
"fmt"
"github.com/cloudfoundry/gosigar"
"os"
)
const output_format = "%-15s %4s %4s %5s %4s %-15s\n"
func formatSize(size uint64) string {
return sigar.FormatSize(size * 1024)
}
func main() {
fslist := sigar.FileSystemList{}
fslist.Get()
fmt.Fprintf(os.Stdout, output_format,
"Filesystem", "Size", "Used", "Avail", "Use%", "Mounted on")
for _, fs := range fslist.List {
dir_name := fs.DirName
usage := sigar.FileSystemUsage{}
usage.Get(dir_name)
fmt.Fprintf(os.Stdout, output_format,
fs.DevName,
formatSize(usage.Total),
formatSize(usage.Used),
formatSize(usage.Avail),
sigar.FormatPercent(usage.UsePercent()),
dir_name)
}
}
|