du

package
v0.0.0-...-7d312d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJSONReport

func GenerateJSONReport(ctx context.Context, rootDir *Dir, rootPath string, maxDepth int, human bool) (string, error)

GenerateJSONReport generates and prints a JSON report of the disk usage in the given directory. maxDepth controls how many directory levels are displayed; if zero, there is no maximum depth. human causes the report to use human-readable units instead of raw bytes.

func GenerateReport

func GenerateReport(ctx context.Context, rootDir *Dir, rootPath string, maxDepth int, human bool) (string, error)

GenerateReport generates a textual report of the disk usage in the given directory. maxDepth controls how many directory levels are displayed; if zero, there is no maximum depth. human causes the report to use human- readable units instead of raw bytes.

func PrintJSONReport

func PrintJSONReport(ctx context.Context, rootPath string, maxDepth int, human bool) error

PrintJSONReport generates and prints a JSON report of the disk usage in the given directory. maxDepth controls how many directory levels are displayed; if zero, there is no maximum depth. human causes the report to use human- readable units instead of raw bytes.

func PrintReport

func PrintReport(ctx context.Context, rootPath string, maxDepth int, human bool) error

PrintReport generates and prints a textual report of the disk usage in the given directory. maxDepth controls how many directory levels are displayed; if zero, there is no maximum depth. human causes the report to use human- readable units instead of raw bytes.

Types

type Dir

type Dir struct {
	Name       string
	Dirs       []*Dir
	Files      []*File
	TotalSize  uint64
	TotalFiles uint64
}

Dir represents a directory and all of its files and subdirectories, along with their total counts and sizes.

func Usage

func Usage(ctx context.Context, rootPath string) (*Dir, error)

Usage produces a report of disk usage within the given directory.

type DirSlice

type DirSlice []*Dir

DirSlice is used for sorting.

func (DirSlice) Len

func (s DirSlice) Len() int

Len implements sort.Interface.

func (DirSlice) Less

func (s DirSlice) Less(a, b int) bool

Less implements sort.Interface.

func (DirSlice) Swap

func (s DirSlice) Swap(a, b int)

Swap implements sort.Interface.

type File

type File struct {
	Name string
	Size uint64
}

File represents a single file and its size in bytes.

type FileSlice

type FileSlice []*File

FileSlice is used for sorting.

func (FileSlice) Len

func (s FileSlice) Len() int

Len implements sort.Interface.

func (FileSlice) Less

func (s FileSlice) Less(a, b int) bool

Less implements sort.Interface.

func (FileSlice) Swap

func (s FileSlice) Swap(a, b int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL