convert

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoxStyle = TableStyle{
	TopLeft: "┌", TopRight: "┐", BottomLeft: "└", BottomRight: "┘",
	Horizontal: "─", Vertical: "│",
	LeftT: "├", RightT: "┤", TopT: "┬", BottomT: "┴", Cross: "┼",
}
View Source
var SimpleStyle = TableStyle{
	TopLeft: "+", TopRight: "+", BottomLeft: "+", BottomRight: "+",
	Horizontal: "-", Vertical: "|",
	LeftT: "+", RightT: "+", TopT: "+", BottomT: "+", Cross: "+",
}

Functions

func BytesConvert

func BytesConvert(input string, decimal bool) (string, error)

BytesConvert auto-detects direction. If input is a plain number, converts to human. If input has units, converts to bytes.

func BytesToHuman

func BytesToHuman(bytes int64, decimal bool) string

BytesToHuman converts a byte count to a human-readable string.

func CSVToJSON

func CSVToJSON(input []byte, delimiter rune) ([]byte, error)

func ChmodExplain

func ChmodExplain(input string) (string, error)

ChmodExplain auto-detects the input format and returns a detailed explanation.

func ChmodToNumeric

func ChmodToNumeric(symbolic string) (string, error)

ChmodToNumeric converts symbolic permission like "rwxr-xr-x" to numeric like "755".

func ChmodToSymbolic

func ChmodToSymbolic(numeric string) (string, error)

ChmodToSymbolic converts numeric permission like "755" or "4755" to symbolic like "rwxr-xr-x".

func ConvertBase

func ConvertBase(input string, fromBase, toBase int) (string, error)

func ConvertDateTime

func ConvertDateTime(input string, fromFmt, toFmt, tz string) (string, error)

func CronExplain

func CronExplain(expr string) (string, error)

func CronNext

func CronNext(expr string, n int, from time.Time) ([]time.Time, error)

func DurationConvert

func DurationConvert(input string, to string) (string, error)

DurationConvert converts between seconds and human-readable duration formats. The `to` parameter can be "human", "seconds", "minutes", "hours", or "" (auto).

func HumanToBytes

func HumanToBytes(input string) (int64, error)

HumanToBytes converts a human-readable size string to bytes.

func JSONToCSV

func JSONToCSV(input []byte, delimiter rune) ([]byte, error)

func JSONToYAML

func JSONToYAML(input []byte) ([]byte, error)

func ToTable

func ToTable(input []byte, style string, inputFormat string, delimiter rune) (string, error)

ToTable converts JSON or CSV input to a formatted table string.

func YAMLToJSON

func YAMLToJSON(input []byte, indent int) ([]byte, error)

Types

type TableStyle

type TableStyle struct {
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Horizontal  string
	Vertical    string
	LeftT       string
	RightT      string
	TopT        string
	BottomT     string
	Cross       string
}

Jump to

Keyboard shortcuts

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