fmtutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package fmtutil provide some format util functions.

Index

Constants

View Source
const (
	OneKByte = 1024
	OneMByte = 1024 * 1024
	OneGByte = 1024 * 1024 * 1024
)

data size

Variables

This section is empty.

Functions

func ArgsWithSpaces

func ArgsWithSpaces(args []any) (message string)

ArgsWithSpaces it like Println, will add spaces for each argument

func DataSize

func DataSize(size uint64) string

DataSize format bytes number friendly.

Usage:

file, err := os.Open(path)
fl, err := file.Stat()
fmtSize := DataSize(fl.Size())

func HowLongAgo

func HowLongAgo(sec int64) string

HowLongAgo format a seconds, get how lang ago

func ParseByte

func ParseByte(sizeStr string) uint64

ParseByte converts size string like 1GB/1g or 12mb/12M into an unsigned integer number of bytes

func PrettyJSON

func PrettyJSON(v any) (string, error)

PrettyJSON get pretty Json string

func SizeToString

func SizeToString(size uint64) string

SizeToString alias of the DataSize

func StringToByte

func StringToByte(sizeStr string) uint64

StringToByte alias of the ParseByte

func StringsToInts

func StringsToInts(ss []string) (ints []int, err error)

StringsToInts string slice to int slice. Deprecated: please use the arrutil.StringsToInts()

Types

This section is empty.

Jump to

Keyboard shortcuts

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