pathsize

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 4 Imported by: 0

README

Pathsize

Go

Overview

Pathsize is a small CLI utility that prints the size of a file or directory.

Features

  • Show the size of a single file or directory
  • Support recursive directory traversal
  • Optionally include hidden files and directories
  • Output sizes in either raw bytes or human-readable format

Installation

Install the CLI binary with:

go install ./cmd/pathsize

After installation, run:

pathsize <path>

Library usage

The package can also be used as a Go library by importing it from the module root:

import "github.com/CosmoS1X/pathsize"

size, err := pathsize.Get(path, recursive, human, all)

Get returns the formatted size as a string and an error if the path cannot be read.

Parameters:

  • path — the file or directory to inspect
  • recursive — if true, directories are traversed recursively
  • human — if true, the result is formatted in human-readable units
  • all — if true, hidden files and directories are included in the calculation

Usage

pathsize [options] <path>
Options
  • -r, --recursive — calculate the size of directories recursively
  • -H, --human — display sizes in a human-readable format
  • -a, --all — include hidden files and directories
  • -h, --help — show help information

Examples

Show the size of a file in bytes:

pathsize testdata/test.txt

Show a directory size recursively:

pathsize -r testdata

Show a human-readable size for a directory:

pathsize -H testdata

Include hidden entries in the calculation:

pathsize -a testdata

Combine multiple flags in one command:

pathsize -raH testdata

Output format

The program prints:

<size>    <path>

For example:

6B    testdata/test.txt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(path string, recursive, human, all bool) (string, error)

Get returns the size of a file or directory at the given path. If recursive is true, the size of directories is calculated recursively. If human is true, the size is returned in a human-readable format. If all is true, hidden files and directories are included in the size calculation.

Types

This section is empty.

Directories

Path Synopsis
cmd
pathsize command

Jump to

Keyboard shortcuts

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