utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// number
	RePositiveInterger           = "^[1-9]\\d*$"
	RePositiveScientificNotation = "^(\\d+(.{0}|.\\d+))[Ee]{1}([\\+|-]?\\d+)$"
	RePositiveFloatPoint         = "^(?:[1-9][0-9]*\\.[0-9]+|0\\.(?!0+$)[0-9]+)$"

	// file&path
	ReURL      = "[\\w-]+(/[\\w-./?%&=]*)?"
	ReFileName = "^[a-zA-Z0-9-_\\.]+$"

	// phone
	ReChinesePhone = "^1\\d{10}$"

	// name
	ReUserName = "^[a-zA-Z0-9_-]+$"
)

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(opts interface{}, parent string) error

CheckConfig

func ClearByteArrayMemory

func ClearByteArrayMemory(bs ...[]byte)

func ClearStringMemory

func ClearStringMemory(s ...string)

func Date

func Date() string

func DateAndTime

func DateAndTime(n int64) (string, string)

func DoLog

func DoLog(userid, username, action, access, result string)

func Expiry

func Expiry(expiry int64) int64

func ExpiryReduceSecond

func ExpiryReduceSecond(expiry int64) time.Time

func GCD

func GCD(a, b int) int

greatest common divisor (GCD) via Euclidean algorithm

func GenRandoms

func GenRandoms(max, total int) []int

func IsChinesePhone

func IsChinesePhone(phone string) bool

func IsExpiry

func IsExpiry(expiry int64) bool

func IsPath

func IsPath(url string) bool

func IsPictureName

func IsPictureName(pictureName string) bool

func IsPositiveFloatPoint

func IsPositiveFloatPoint(num string) bool

func IsPositiveInterger

func IsPositiveInterger(num string) bool

validator

func IsPositiveScientificNotation

func IsPositiveScientificNotation(num string) bool

func IsSafeFileName

func IsSafeFileName(name string) bool

func IsTxt

func IsTxt(fileName string) bool

func IsUserName

func IsUserName(name string) bool

func LCM

func LCM(a, b int) int

find Least Common Multiple (LCM) via GCD

func LoadFromYaml

func LoadFromYaml(path string, cfg interface{}) error

func Now

func Now() int64

func RetryThreeTimes

func RetryThreeTimes(f func() error)

func StrLen

func StrLen(s string) int

func ToDate

func ToDate(n int64) string

func ToUnixTime

func ToUnixTime(v string) (time.Time, error)

func ToUnixTimeLayout2

func ToUnixTimeLayout2(v string) (time.Time, error)

func XSSFilter

func XSSFilter(input string) (output string)

filter

Types

type SymmetricEncryption

type SymmetricEncryption interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

func NewSymmetricEncryption

func NewSymmetricEncryption(key, nonce string) (SymmetricEncryption, error)

Jump to

Keyboard shortcuts

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