utils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Byte byte
	Byte = 1
	// KByte kbyte
	KByte = Byte * 1024
	// MByte mbyte
	MByte = KByte * 1024
	// GByte gbyte
	GByte = MByte * 1024
	// TByte tbyte
	TByte = GByte * 1024
	// PByte pbyte
	PByte = TByte * 1024
	// EByte ebyte
	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 CompareVersion

func CompareVersion(src, toCompare string) bool

CompareVersion compare version

func CompressedContent

func CompressedContent(h *template.HTML)

CompressedContent compressed comtent

func CopyMap

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

CopyMap copy map

func FileExist

func FileExist(path string) bool

FileExist file exist

func FileSize

func FileSize(s uint64) string

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

func InArray

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

InArray in array

func IsJSON

func IsJSON(str string) bool

IsJSON is json

func JSON

func JSON(a interface{}) string

JSON json

func ParseBool

func ParseBool(s string) bool

ParseBool parse bool

func ParseFloat32

func ParseFloat32(f string) float32

ParseFloat32 parse float

func Random

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

Random random

func ReplaceNth

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

ReplaceNth replace nth

func TimeSincePro

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

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

func UUID

func UUID(length int64) string

UUID uuid

func WrapURL

func WrapURL(u string) string

WrapURL warp url

Types

type Collection

type Collection []map[string]interface{}

Collection collection

func (Collection) FirstGet

func (c Collection) FirstGet(key string) interface{}

FirstGet first get

func (Collection) Length

func (c Collection) Length() int

Length length

func (Collection) Where

func (c Collection) Where(key string, values ...interface{}) Collection

Where filters the collection by a given key / value pair.

type Handler

type Handler interface{}

Handler handler

Jump to

Keyboard shortcuts

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