util

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReWhiteSpace     *regexp.Regexp
	ReFieldWhiteList *regexp.Regexp
	ReUserName       *regexp.Regexp
)

Functions

func BoolToString

func BoolToString(b bool) string

func CamelToSnakeCase

func CamelToSnakeCase(camel string) string

CamelToSnakeCase This function transform camelcase in snakecase LoremIpsum in lorem_ipsum

func CasbinToSlice

func CasbinToSlice(casbinRule xormadapter.CasbinRule) []string

func ContainsString

func ContainsString(values []string, val string) bool

func DeleteVal

func DeleteVal(values []string, val string) []string

func FileExist

func FileExist(path string) bool

func FilterField

func FilterField(field string) bool

func FilterQuery

func FilterQuery(urlString string, blackList []string) string

func GenerateClientId

func GenerateClientId() string

func GenerateClientSecret

func GenerateClientSecret() string

func GenerateId

func GenerateId() string

func GenerateSimpleTimeId

func GenerateSimpleTimeId() string

func GenerateTimeId

func GenerateTimeId() string

func GetCountryCode

func GetCountryCode(prefix string, phone string) (string, error)

func GetCurrentTime

func GetCurrentTime() string

func GetCurrentTimeEx

func GetCurrentTimeEx(timestamp string) string

func GetCurrentUnixTime

func GetCurrentUnixTime() string

func GetE164Number

func GetE164Number(phone string, countryCode string) (string, bool)

func GetEndPoint

func GetEndPoint(endpoint string) string

GetEndPoint remove scheme from url

func GetHmacSha1

func GetHmacSha1(keyStr, value string) string

func GetHmacSha256

func GetHmacSha256(key string, data string) string

func GetIPFromRequest

func GetIPFromRequest(req *http.Request) string

func GetIPInfo

func GetIPInfo(clientIP string) string

func GetId

func GetId(owner, name string) string

func GetMaskedEmail

func GetMaskedEmail(email string) string

func GetMaskedPhone

func GetMaskedPhone(phone string) string

func GetMd5Hash

func GetMd5Hash(text string) string

func GetOwnerAndNameAndOtherFromId

func GetOwnerAndNameAndOtherFromId(id string) (string, string, string)

func GetOwnerAndNameFromId

func GetOwnerAndNameFromId(id string) (string, string)

func GetOwnerAndNameFromIdNoCheck

func GetOwnerAndNameFromIdNoCheck(id string) (string, string)

func GetOwnerAndNameFromIdWithError

func GetOwnerAndNameFromIdWithError(id string) (string, string, error)

func GetOwnerFromId

func GetOwnerFromId(id string) string

func GetPath

func GetPath(path string) string

func GetRandomName

func GetRandomName() string

func GetSessionId

func GetSessionId(owner, name, application string) string

func GetSharedOrgFromApp

func GetSharedOrgFromApp(rawName string) (name string, organization string)

func GetUploadXlsxPath

func GetUploadXlsxPath(fileId string) string

func GetUrlHost

func GetUrlHost(urlString string) string

func GetUrlPath

func GetUrlPath(urlString string) string

func GetUsernameFromEmail

func GetUsernameFromEmail(email string) string

func GetValueFromDataSourceName

func GetValueFromDataSourceName(key string, dataSourceName string) string

func HasString

func HasString(strs []string, str string) bool

HasString reports if slice has input string.

func HaveIntersection

func HaveIntersection(arr1 []string, arr2 []string) bool

func InSlice

func InSlice(slice []string, elem string) bool

func IsChinese

func IsChinese(str string) bool

func IsEmailValid

func IsEmailValid(email string) bool

func IsInvitationCodeMatch

func IsInvitationCodeMatch(pattern string, invitationCode string) (bool, error)

func IsPhoneAllowInRegin

func IsPhoneAllowInRegin(countryCode string, allowRegions []string) bool

func IsPhoneValid

func IsPhoneValid(phone string, countryCode string) bool

func IsRegexp

func IsRegexp(s string) (bool, error)

func IsStringsEmpty

func IsStringsEmpty(strs ...string) bool

func IsTokenExpired

func IsTokenExpired(createdTime string, expiresIn int) (bool, string)

func JsonToStruct

func JsonToStruct(data string, v interface{}) error

func ListFiles

func ListFiles(path string) []string

func LogInfo

func LogInfo(ctx *context.Context, f string, v ...interface{})

func LogWarning

func LogWarning(ctx *context.Context, f string, v ...interface{})

func MatrixToCasbinRules

func MatrixToCasbinRules(Ptype string, policies [][]string) []*xormadapter.CasbinRule

func ParseBool

func ParseBool(s string) bool

func ParseFloat

func ParseFloat(s string) float64

func ParseIdToString

func ParseIdToString(input interface{}) (string, error)

func ParseInt

func ParseInt(s string) int

func ParseIntWithError

func ParseIntWithError(s string) (int, error)

func ReadStringFromPath

func ReadStringFromPath(path string) string

func RemoveExt

func RemoveExt(filename string) string

func ReplaceVal

func ReplaceVal(values []string, oldVal string, newVal string) []string

func ReturnAnyNotEmpty

func ReturnAnyNotEmpty(strs ...string) string

func SafeGoroutine

func SafeGoroutine(fn func())

func SnakeString

func SnakeString(s string) string

SnakeString transform XxYy to xx_yy

func SnakeToCamel

func SnakeToCamel(snake string) string

func SpaceToCamel

func SpaceToCamel(name string) string

func String2Time

func String2Time(timestamp string) time.Time

func StringToInterfaceArray

func StringToInterfaceArray(array []string) []interface{}

func StringToInterfaceArray2d

func StringToInterfaceArray2d(arrays [][]string) [][]interface{}

func StructToJson

func StructToJson(v interface{}) string

func StructToJsonFormatted

func StructToJsonFormatted(v interface{}) string

func Time2String

func Time2String(timestamp time.Time) string

func TryJsonToAnonymousStruct

func TryJsonToAnonymousStruct(j string) (interface{}, error)

func UrlJoin

func UrlJoin(base string, path string) string

func WriteStringToPath

func WriteStringToPath(s string, path string)

Types

type SystemInfo

type SystemInfo struct {
	CpuUsage    []float64 `json:"cpuUsage"`
	MemoryUsed  uint64    `json:"memoryUsed"`
	MemoryTotal uint64    `json:"memoryTotal"`
}

func GetSystemInfo

func GetSystemInfo() (*SystemInfo, error)

type VersionInfo

type VersionInfo struct {
	Version      string `json:"version"`
	CommitId     string `json:"commitId"`
	CommitOffset int    `json:"commitOffset"`
}

func GetVersionInfo

func GetVersionInfo() (*VersionInfo, error)

GetVersionInfo get git current commit and repo release version

Jump to

Keyboard shortcuts

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