func main() { usage, err := du.Get(os.Args[1]) if err != nil { log.Fatal(err) } fmt.Println("Free:", usage.FreeBytes/(KB*KB), "MiB") fmt.Println("Available:", usage.AvailBytes/(KB*KB), "MiB") fmt.Println("Size:", usage.TotalBytes/(KB*KB), "MiB") }
func DiskFreePercentage(path string) (freePct float64, err error) { u, err := du.Get(path) return (float64(u.FreeBytes) / float64(u.TotalBytes)) * 100, err }
func DiskFreeBytes(path string) (free int64, err error) { u, err := du.Get(path) return u.FreeBytes, err }
func DuPath(path string) (free int64, err error) { u, err := du.Get(path) fmt.Println("Path:", path, "FreeBytes:", u.FreeBytes, "TotalBytes:", u.TotalBytes) return u.FreeBytes, err }