utils

package module
v0.0.0-...-2fffea7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 13 Imported by: 1

README

说明

GIN + ENT/SQLX + CASBIN + WIRE + I18N

为了保持系统精简性(目前数据库处理只使用SQLX), 暂时移除了ENT相关的内容, 结构暂时保留

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 FindArrayInterface

func FindArrayInterface(ds []interface{}, checkor func(interface{}) bool) (int, interface{})

FindArrayInterface ...

func FindArrayString

func FindArrayString(ds []string, checkor func(string) bool) (int, string)

FindArrayString ...

func ForEache

func ForEache(ds interface{}, next func(interface{}) (bool, error)) (err error)

ForEache ...

func IfBool

func IfBool(condition bool, ifture, ifalse bool) bool

IfBool 判断

func IfExec

func IfExec(condition bool, ifture, ifalse func())

IfExec 判断

func IfFunc

func IfFunc(condition bool, ifture, ifalse func() interface{}) interface{}

IfFunc 判断

func IfInt

func IfInt(condition bool, ifture, ifalse int) int

IfInt 判断

func IfObject

func IfObject(condition bool, ifture, ifalse interface{}) interface{}

IfObject 判断

func IfString

func IfString(condition bool, ifture, ifalse string) string

IfString 判断

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 ReverseStr

func ReverseStr(s string) string

ReverseStr 反正字符串

func SplitStrCR

func SplitStrCR(s string, x rune, c int) string

SplitStrCR 截取字符串

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