utils

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: Apache-2.0 Imports: 19 Imported by: 140

Documentation

Index

Constants

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)
View Source
const (
	Minute = 60
	Hour   = 60 * Minute
	Day    = 24 * Hour
	Week   = 7 * Day
	Month  = 30 * Day
	Year   = 12 * Month
)

Seconds-based time units

Variables

This section is empty.

Functions

func AorB added in v1.2.15

func AorB(condition bool, a, b string) string

func CompareVersion added in v1.2.9

func CompareVersion(src, toCompare string) bool

func CompressedContent added in v1.1.7

func CompressedContent(h *template.HTML)

func CopyMap added in v1.2.3

func CopyMap(m map[string]string) map[string]string

func DownloadTo added in v1.2.15

func DownloadTo(url, output string) error

func FileExist added in v1.2.12

func FileExist(path string) bool

func FileSize added in v1.2.9

func FileSize(s uint64) string

FileSize calculates the file size and generate user-friendly string.

func InArray added in v1.2.3

func InArray(arr []string, str string) bool

func IsJSON added in v1.2.8

func IsJSON(str string) bool

func JSON added in v1.2.8

func JSON(a interface{}) string

func PackageName added in v1.2.15

func PackageName(v interface{}) string

func ParseBool added in v1.2.8

func ParseBool(s string) bool

func ParseFloat32 added in v1.2.9

func ParseFloat32(f string) float32

func ParseHTML added in v1.2.16

func ParseHTML(name, tmpl string, param interface{}) template.HTML

func ParseText added in v1.2.16

func ParseText(name, tmpl string, param interface{}) string

func ParseTime added in v1.2.15

func ParseTime(stringTime string) time.Time

func Random

func Random(strings []string) ([]string, error)

func ReplaceAll added in v1.2.16

func ReplaceAll(s string, oldnew ...string) string

func ReplaceNth added in v1.2.3

func ReplaceNth(s, old, new string, n int) string

func SetDefault added in v1.2.9

func SetDefault(value, condition, def string) string

func TimeSincePro added in v1.2.9

func TimeSincePro(then time.Time, m map[string]string) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func UnzipDir added in v1.2.15

func UnzipDir(src, dest string) error

func Uuid

func Uuid(length int64) string

func WrapURL added in v1.2.7

func WrapURL(u string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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