Documentation
¶
Overview ¶
Package fmtutil provide some format util functions.
Index ¶
- Constants
- func ArgsWithSpaces(vs []any) (message string)
- func DataSize(size uint64) string
- func FormatDuration(d time.Duration) string
- func HowLongAgo(sec int64) string
- func HumanSize(size uint64) 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 ¶
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 FormatDuration ¶ added in v0.7.2
FormatDuration Formatting time consumption is clock format 格式化时间消耗为时钟格式 eg: 90 * time.Second => "01:30"
func ParseByte ¶
ParseByte converts size string like 1GB/1g or 12mb/12M into an unsigned integer number of bytes
func StringOrJSON ¶
StringOrJSON to string or encode pretty JSON data to json bytes.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.