util

package
v1.519.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 38 Imported by: 13

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 added in v1.166.0

func CasbinToSlice(casbinRule xormadapter.CasbinRule) []string

func ContainsString added in v1.245.0

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

func DeleteVal added in v1.207.0

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

func FileExist

func FileExist(path string) bool

func FilterField added in v1.351.2

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 added in v1.29.0

func GenerateSimpleTimeId() string

func GenerateTimeId added in v1.27.6

func GenerateTimeId() string

func GetCountryCode added in v1.309.0

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

func GetCurrentTime

func GetCurrentTime() string

func GetCurrentTimeEx added in v1.309.0

func GetCurrentTimeEx(timestamp string) string

func GetCurrentUnixTime

func GetCurrentUnixTime() string

func GetE164Number added in v1.245.0

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

func GetEndPoint added in v1.298.0

func GetEndPoint(endpoint string) string

GetEndPoint remove scheme from url

func GetHmacSha1 added in v1.62.0

func GetHmacSha1(keyStr, value string) string

func GetHmacSha256 added in v1.81.0

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 added in v1.29.1

func GetMaskedEmail(email string) string

func GetMaskedPhone added in v1.29.1

func GetMaskedPhone(phone string) string

func GetMd5Hash

func GetMd5Hash(text string) string

func GetOwnerAndNameAndOtherFromId added in v1.239.0

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

func GetOwnerAndNameFromId

func GetOwnerAndNameFromId(id string) (string, string)

func GetOwnerAndNameFromIdNoCheck

func GetOwnerAndNameFromIdNoCheck(id string) (string, string)

func GetOwnerFromId added in v1.288.0

func GetOwnerFromId(id string) string

func GetPath

func GetPath(path string) string

func GetRandomName added in v1.309.0

func GetRandomName() string

func GetSessionId added in v1.239.0

func GetSessionId(owner, name, application string) string

func GetUploadXlsxPath

func GetUploadXlsxPath(fileId string) string

func GetUrlHost

func GetUrlHost(urlString string) string

func GetUrlPath

func GetUrlPath(urlString string) string

func GetUsernameFromEmail added in v1.419.0

func GetUsernameFromEmail(email string) string

func GetValueFromDataSourceName added in v1.406.0

func GetValueFromDataSourceName(key string, dataSourceName string) string

func HasString added in v1.341.0

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

HasString reports if slice has input string.

func HaveIntersection added in v1.439.0

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

func InSlice added in v1.352.0

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

func IsChinese

func IsChinese(str string) bool

func IsEmailValid

func IsEmailValid(email string) bool

func IsInvitationCodeMatch added in v1.510.0

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

func IsPhoneAllowInRegin added in v1.245.0

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

func IsPhoneValid added in v1.245.0

func IsPhoneValid(phone string, countryCode string) bool

func IsRegexp added in v1.510.0

func IsRegexp(s string) (bool, error)

func IsStringsEmpty added in v1.245.1

func IsStringsEmpty(strs ...string) bool

func IsTokenExpired added in v1.15.0

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

func JsonToStruct

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

func ListFiles added in v1.101.2

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 added in v1.393.0

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

func ParseBool

func ParseBool(s string) bool

func ParseFloat added in v1.27.6

func ParseFloat(s string) float64

func ParseIdToString added in v1.358.0

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

func ParseInt

func ParseInt(s string) int

func ParseIntWithError added in v1.474.0

func ParseIntWithError(s string) (int, error)

func ReadStringFromPath

func ReadStringFromPath(path string) string

func RemoveExt

func RemoveExt(filename string) string

func ReplaceVal added in v1.343.0

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

func ReturnAnyNotEmpty added in v1.293.0

func ReturnAnyNotEmpty(strs ...string) string

func SafeGoroutine added in v1.44.3

func SafeGoroutine(fn func())

func SnakeString

func SnakeString(s string) string

SnakeString transform XxYy to xx_yy

func SnakeToCamel added in v1.387.1

func SnakeToCamel(snake string) string

func String2Time added in v1.430.0

func String2Time(timestamp string) time.Time

func StringToInterfaceArray added in v1.483.0

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

func StringToInterfaceArray2d added in v1.483.0

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

func StructToJson

func StructToJson(v interface{}) string

func StructToJsonFormatted

func StructToJsonFormatted(v interface{}) string

func Time2String added in v1.434.1

func Time2String(timestamp time.Time) string

func TryJsonToAnonymousStruct added in v1.519.0

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 added in v1.265.0

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

func GetSystemInfo added in v1.265.0

func GetSystemInfo() (*SystemInfo, error)

type VersionInfo added in v1.265.0

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

func GetVersionInfo added in v1.265.0

func GetVersionInfo() (*VersionInfo, error)

GetVersionInfo get git current commit and repo release version

func GetVersionInfoFromFile added in v1.268.0

func GetVersionInfoFromFile() (*VersionInfo, error)

Jump to

Keyboard shortcuts

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