tools

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 4 Imported by: 0

README

tools

set of utility functions

  • PrettyByteSize - returns a human readable string of int bytes

    ${999 => 999 \color{green}\space B}$
    ${2048 => 2.0 \color{green}\space KiB}$
    ${1058575 => 1.01 \color{green}\space MiB}$

packages

logging

slog helpers

  • create logger with default, disard, text or json handler
  • options to set output, loglevel, timeformat, include source, truncate source
config

configuration helper

  • reads yaml config file from XDG_CONFIG_HOME i.e. ~/.config/progname/config into user supplied struct
  • value is cached for quicker subsequent lookups
money

small currency package for handling money

  • supports curreny values up to 100 trillon
  • helper funcs for tax calculations

Documentation

Overview

Package tools implements utility routines

Index

Constants

View Source
const (
	// Escape is ansi terminal escape sequence.
	Escape = "\x1b["
	// Reset is ansi termnial code for reset.
	Reset = Escape + "0m"
	// Green is ansi terminal code for green text.
	Green = Escape + "32m"
)

Variables

This section is empty.

Functions

func PrettyByteSize

func PrettyByteSize(b int) string

PrettyByteSize formats a byte size (int) into a human-readable colored string using binary prefixes (KiB, MiB, etc.).

func UseColour added in v0.2.1

func UseColour() bool

UseColour checks if output is a terminal or whether colour output has been suppresed in env.

Types

This section is empty.

Directories

Path Synopsis
Package config reads a yaml config file from the XDG_CONFIG_HOME and unmarshals it into a user supplied struct
Package config reads a yaml config file from the XDG_CONFIG_HOME and unmarshals it into a user supplied struct
Package logging provides slog helpers.
Package logging provides slog helpers.
Package money is a simple currency package
Package money is a simple currency package

Jump to

Keyboard shortcuts

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