util

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteStringToNumber

func ByteStringToNumber(input string) (uint64, error)

ByteStringToNumber parses human-readable byte strings like "500MB", "2GiB"

func ExtractFilenameFromURL

func ExtractFilenameFromURL(urlStr string) string

ExtractFilenameFromURL extracts the filename from a URL path

func HumanizeBytes

func HumanizeBytes(bytes uint64) string

HumanizeBytes formats bytes as human-readable string (KiB, MiB, GiB, TiB)

func ParseUsizeRange

func ParseUsizeRange(value string, maxValue int) ([]int, error)

ParseUsizeRange parses a range string and returns all values in that range. Supported formats: - Single value: "42" -> [42] - Range with beginning and end: "1-5" -> [1,2,3,4,5] - Range with no end: "10-" -> [10...maxValue] - Range with no beginning: "-5" -> [1,2,3,4,5] Note: ranges start at 1, not 0

func ReplaceInvalidCharsInFilename

func ReplaceInvalidCharsInFilename(input string) string

ReplaceInvalidCharsInFilename sanitizes filenames by replacing invalid characters

func StrVectorsIntersect

func StrVectorsIntersect(first, second []string) bool

StrVectorsIntersect checks if two string slices have any common element (case-insensitive)

func UnionUsizeRanges

func UnionUsizeRanges(values []string, maxValue int) ([]int, error)

UnionUsizeRanges parses multiple range strings and returns the union of all values

Types

type TableBuilder

type TableBuilder struct {
	// contains filtered or unexported fields
}

TableBuilder wraps tablewriter for consistent formatting

func NewTable

func NewTable(headers []string) *TableBuilder

NewTable creates a new table with the given headers

func (*TableBuilder) AddRow

func (tb *TableBuilder) AddRow(row []string)

AddRow adds a row to the table

func (*TableBuilder) Render

func (tb *TableBuilder) Render()

Render renders the table to stdout

Jump to

Keyboard shortcuts

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