utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PadStringLeft

func PadStringLeft(input string, padChar string, length int) string

Example: PadStringLeft("hello", "*", 8) returns "***hello"

Note: The function adds a space to the input string before padding to ensure proper alignment.

func PadStringRight

func PadStringRight(input string, padChar string, length int) string

PadStringRight pads the input string with the specified padChar on the right side until the string reaches the specified length. If the input string is already longer than or equal to the specified length, it returns the input string as is.

Parameters: - input: The original string to be padded. - padChar: The character to pad the input string with. - length: The desired total length of the output string.

Returns: - A new string that is padded with padChar on the right side to the specified length.

Example: PadStringRight("hello", "*", 8) returns "hello***"

Note: The function adds a space to the input string before padding to ensure proper alignment.

func SizeInBytes

func SizeInBytes(size uint64) string

SizeInBytes converts a size in bytes to a human-readable string representation using binary prefixes (KiB, MiB, GiB).

Parameters: - size: The size in bytes to be converted.

Returns: - A string representing the size in a human-readable format with binary prefixes.

Example: SizeInBytes(1048576) returns "1.00 MiB"

Note: The function uses binary prefixes where 1 KiB = 1024 bytes, 1 MiB = 1024 KiB, and 1 GiB = 1024 MiB.

Types

This section is empty.

Directories

Path Synopsis
encoding

Jump to

Keyboard shortcuts

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