utils

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

README

utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDecodingPemBlock decoding PEM block error
	ErrDecodingPemBlock = errors.New("decoding PEM block error")
	// ErrConvertingEcPublicKey converting EC public key error
	ErrConvertingEcPublicKey = errors.New("converting EC public key error")
)

Functions

func After

func After(d time.Duration) *time.Time

After return *time.Time

func CheckKeys added in v0.0.3

func CheckKeys(userRight int64, val func(key string) int64, keys ...string) bool

CheckKeys rbac check right by keys @param val func(key string) get value by key

func CheckVals added in v0.0.3

func CheckVals(userRight int64, vals ...int64) bool

CheckVal rbac check right by vals

func CreatePrivateKey added in v0.0.2

func CreatePrivateKey(privateKeyPEM []byte) (*ecdsa.PrivateKey, error)

CreatePrivateKey return *ecdsa.PrivateKey

func CreatePrivateKeyPEM added in v0.0.2

func CreatePrivateKeyPEM() ([]byte, error)

CreatePrivateKeyPEM create private key pem

func CreatePublicKey added in v0.0.2

func CreatePublicKey(publicKeyPEM []byte) (*ecdsa.PublicKey, error)

CreatePublicKey return *ecdsa.PublicKey

func CreatePublicKeyPEM added in v0.0.2

func CreatePublicKeyPEM(privateKey *ecdsa.PrivateKey) ([]byte, error)

CreatePublicKeyPEM create public key pem

func DirExist added in v0.0.2

func DirExist(dir string) bool

DirExist check dir

func FileExist added in v0.0.2

func FileExist(filename string) bool

FileExist check file

func FileSize added in v0.0.2

func FileSize(size int64) string

FileSize format file size

func HomeDir added in v0.0.2

func HomeDir(path string) (string, error)

HomeDir join path with app home dir

func Int added in v0.0.5

func Int(name string, val int) error

Int validate name

func IsBool added in v0.0.2

func IsBool(attributeType string) bool

IsBool if attribute type is Numeric return true, else false

func IsInt added in v0.0.2

func IsInt(goType string) bool

IsInt when goType is: int int8 int16 int32 int64 return true

func IsNumeric added in v0.0.2

func IsNumeric(attributeType string) bool

Numeric if attribute type is Numeric return true, else false

func MakeCamel added in v0.0.2

func MakeCamel(val string) string

MakeCamel converts the given val to camel case like: user_key to userKey

func MakeCapitalize added in v0.0.2

func MakeCapitalize(str string) string

MakeCapitalize change first character to upper

func MakeKebab added in v0.0.2

func MakeKebab(val string) string

MakeKebab converts the given val to kebab case like: UserKey to user-key

func MakePlural added in v0.0.2

func MakePlural(name string) string

MakePlural convert word to plural

func MakeSafeString added in v0.0.2

func MakeSafeString(val string) string

MakeSafeString make string safe for sql

func MakeSingle added in v0.0.2

func MakeSingle(name string) string

MakeSingle convert word to single

func MakeSnake added in v0.0.2

func MakeSnake(val string) string

MakeSnake converts the given val to snake case like: UserKey,userKey to user_key

func MakeStudly added in v0.0.2

func MakeStudly(val string) string

MakeStudly converts the given val to studly case like: user_key, userKey to UserKey

func MakeTitle added in v0.0.2

func MakeTitle(val string) string

MakeTitle converts the given val to title case like: UserKey,userKey to user_key

func MakeUrl added in v0.0.2

func MakeUrl(val string) string

MakeUrl converts the given val to url like: UserKey to user/key

func MatchAlphabet added in v0.0.2

func MatchAlphabet(val string) bool

MatchAlphabet check alphabet

func MatchDomain added in v0.0.2

func MatchDomain(val string) bool

MatchDomain check domain

func MatchEmail added in v0.0.2

func MatchEmail(val string) bool

MatchEmail check email

func MatchPhone added in v0.0.2

func MatchPhone(val string) bool

MatchPhone check phone

func MySQLSplit added in v0.0.2

func MySQLSplit(data []byte, atEOF bool) (advance int, token []byte, err error)

MySQLSplit split function for the Scanner

func Now

func Now() *time.Time

Now return *time.Time

func RString added in v0.0.5

func RString(name string, val *string) error

RString validate name

func RandomString

func RandomString(len int) (string, error)

RandomString random string

func ReadJSON added in v0.0.2

func ReadJSON(filename string, v interface{}) error

ReadJSON read json to data

func SqlFilter

func SqlFilter(filter string, str *strings.Builder, args *[]interface{}, prefix string, fn func(key string, val string) (string, interface{}, error)) error

SqlFilter create sql for filter and args

func SqlOrderBy

func SqlOrderBy(orderBy string, str *strings.Builder, prefix string, fn func(variableName string) (string, string, string, error)) error

SqlOrderBy create sql for order by

func String added in v0.0.5

func String(name string, val string) error

String validate name

func TarFile added in v0.0.2

func TarFile(src string) (string, error)

TarFile compress file with gzip

func TryParse added in v0.0.2

func TryParse(val string, attributeType string) (interface{}, error)

func Uint64 added in v0.0.5

func Uint64(name string, val uint64) error

Uint64 validate name

func ValidateDomain added in v0.0.2

func ValidateDomain(domain ...string) error

ValidateDomain validate domain

func ValidateEmail added in v0.0.2

func ValidateEmail(email ...string) error

ValidateEmail validate email

func ValidateName added in v0.0.2

func ValidateName(name ...string) error

ValidateName validate name

func ValidatePhone added in v0.0.2

func ValidatePhone(phone ...string) error

ValidatePhone validate phone number

func Where added in v0.0.2

func Where(where string, fn func(key string, op string, val string))

Where parse where

func WriteJSON added in v0.0.2

func WriteJSON(filename string, v interface{}, overwrite bool) error

WriteJSON write data to json

func ZipFile added in v0.0.4

func ZipFile(src string) (string, error)

ZipFile compress file with zip

Types

This section is empty.

Jump to

Keyboard shortcuts

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