util

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UUID3 regex expr
	UUID3 string = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
	// UUID4 regex expr
	UUID4 string = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
	// UUID5 regex expr
	UUID5 string = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
	// UUID regex expr
	UUID string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
	// SLUG regex expr
	SLUG string = "^[a-z0-9]+(?:_[a-z0-9]+)*$"
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(path string) bool

DirExists reports whether the dir exists

func EnsureDir

func EnsureDir(dirName string, mode int) (bool, error)

EnsureDir ensures that directory exists

func FileExists

func FileExists(path string) bool

FileExists reports whether the named file exists

func GenerateJWTToken

func GenerateJWTToken(data string, timestamp int64, secret string) (string, error)

GenerateJWTToken generate a jwt token for frontend

func GenerateUUID4

func GenerateUUID4() string

GenerateUUID4 create a UUID

func Unset

func Unset(a []string, i int) []string

Unset remove element at position i

Types

type Map

type Map struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Map type

func NewMap

func NewMap() Map

NewMap creates a new instance of Map

func (*Map) Delete

func (cm *Map) Delete(key string)

Delete deletes a key

func (*Map) Get

func (cm *Map) Get(key string) (interface{}, bool)

Get a key from a concurrent map

func (*Map) Set

func (cm *Map) Set(key string, value interface{})

Set a key in a concurrent map

type Validator

type Validator struct {
}

Validator util

func (*Validator) IsEmpty

func (v *Validator) IsEmpty(item string) bool

IsEmpty checks if item is empty

func (*Validator) IsIn

func (v *Validator) IsIn(item string, list []string) bool

IsIn checks if item in array

func (*Validator) IsJSON

func (v *Validator) IsJSON(str string) bool

IsJSON validates a JSON string

func (*Validator) IsSlug

func (v *Validator) IsSlug(slug string, min int, max int) bool

IsSlug checks if string is a valid slug

func (*Validator) IsSlugs

func (v *Validator) IsSlugs(slugs []string, min int, max int) bool

IsSlugs checks if string is a valid slug

func (*Validator) IsUUID

func (v *Validator) IsUUID(uuid string) bool

IsUUID validates a UUID

func (*Validator) IsUUID3

func (v *Validator) IsUUID3(uuid string) bool

IsUUID3 validates a UUID3

func (*Validator) IsUUID4

func (v *Validator) IsUUID4(uuid string) bool

IsUUID4 validates a UUID4

func (*Validator) IsUUID5

func (v *Validator) IsUUID5(uuid string) bool

IsUUID5 validates a UUID5

Jump to

Keyboard shortcuts

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