formatter

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

README

go-formatter

Build Status Go Report Card Documentation license GitHub version GitHub issues

This is a Golang library which contains formatting related functions.

Documentation

Index

Constants

View Source
const (
	// BYTE defines a filesize of 1 byte
	BYTE = 1.0

	// KILOBYTE defines a filesize of 1 kilobyte
	KILOBYTE = 1000 * BYTE

	// MEGABYTE defines a filesize of 1 megabyte
	MEGABYTE = 1000 * KILOBYTE

	// GIGABYTE defines a filesize of 1 gigabyte
	GIGABYTE = 1000 * MEGABYTE

	// TERABYTE defines a filesize of 1 terabyte
	TERABYTE = 1000 * GIGABYTE
)

Variables

View Source
var (
	// ErrSQLInvalidStatement is the error returned when the SQL statement is invalid
	ErrSQLInvalidStatement = errors.New("Invalid SQL statement")
)

Functions

func Color

func Color(value string) string

Color formats a color by:

- Stripping the # prefix - Changing all components to uppercase - Making sure it contains 6 digits

func DurationInMilliseconds

func DurationInMilliseconds(d time.Duration) string

DurationInMilliseconds formats a duration as milliseconds (including the suffix "ms")

func Elapsed

func Elapsed(duration int64, empty string) string

Elapsed forrmats a duration in HH:MM:SS showing empty if the duration is less or equal than 0

func FileSize

func FileSize(bytes int64) string

FileSize formats the filesize as a string with a precision of 2 decimals

func FileSizeWithPrecision

func FileSizeWithPrecision(bytes int64, precision int64) string

FileSizeWithPrecision formats the filesize as a string with a custom precision

func FloatWithPrecision

func FloatWithPrecision(value float64, precision int64) string

FloatWithPrecision formats a float with a custom precision

func IntWithSeparators

func IntWithSeparators(number int64) string

IntWithSeparators formats an integer with separators using the language Dutch

func JSONBytes

func JSONBytes(data []byte) (string, error)

JSONBytes pretty prints a slice of JSON bytes

func JSONString

func JSONString(data string) (string, error)

JSONString pretty prints a JSON string

func SQL

func SQL(sql string) (string, error)

SQL formats an SQL query

func UnixTimestamp

func UnixTimestamp(sec int64, layout string) string

UnixTimestamp formats a unix timestamp with the given layout

func XML

func XML(xmlString string) (string, error)

XML formats an XML string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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