Documentation ¶
Overview ¶
Package fmtutil provide some format util functions.
Index ¶
- Constants
- func ArgsWithSpaces(vs []any) (message string)
- func DataSize(size uint64) string
- func HowLongAgo(sec int64) string
- func ParseByte(sizeStr string) uint64
- func PrettyJSON(v any) (string, error)
- func SizeToString(size uint64) string
- func StringOrJSON(v any) ([]byte, error)
- func StringToByte(sizeStr string) uint64
Constants ¶
View Source
const ( OneKByte = 1024 OneMByte = 1024 * 1024 OneGByte = 1024 * 1024 * 1024 )
data size
Variables ¶
This section is empty.
Functions ¶
func ArgsWithSpaces ¶ added in v0.3.8
ArgsWithSpaces it like Println, will add spaces for each argument
func DataSize ¶
DataSize format bytes number friendly.
Usage:
file, err := os.Open(path) fl, err := file.Stat() fmtSize := DataSize(fl.Size())
func ParseByte ¶ added in v0.5.6
ParseByte converts size string like 1GB/1g or 12mb/12M into an unsigned integer number of bytes
func PrettyJSON ¶ added in v0.2.2
PrettyJSON get pretty Json string
func SizeToString ¶ added in v0.5.6
SizeToString alias of the DataSize
func StringOrJSON ¶ added in v0.6.8
StringOrJSON to string or encode pretty JSON data to json bytes.
func StringToByte ¶ added in v0.5.6
StringToByte alias of the ParseByte
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.