utils

package
v0.0.0-...-f226d47 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQueryToURL

func AddQueryToURL(urlStr string, queryMap map[string]string) string

func CheckFileExist

func CheckFileExist(path string) bool

func ContainsStr

func ContainsStr(s []string, v string) bool

ContainsStr returns true if an str is present in a iteratee.

func CopyStruct

func CopyStruct(src *map[string]interface{}, dest *map[string]interface{}) error

func EnsureDir

func EnsureDir(dir string) error

EnsureDir ensures that a target directory exists (like `mkdir -p`),

func GetMD5Hash

func GetMD5Hash(text string) string

func JsonObjInArrAnyStr

func JsonObjInArrAnyStr(jsonStr string) string

将 JSON "数组中的"对象的 Values 全部转成 String 类型 @note Array style is not the same as JSON Array, it uses the ToString() function.

[{"a":233}, {"b":true}, {"c":"233"}]
=> [{"a":"233"}, {"b":"true"}, {"c":"233"}]

@relevant ToString()

func Marked

func Marked(markdownStr string) (string, error)

func PseudorandomString

func PseudorandomString(length int) string

PseudorandomString generates a pseudorandom string with the specified length.

The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.

For a cryptographically random string (but a little bit slower) use RandomString instead.

func PseudorandomStringWithAlphabet

func PseudorandomStringWithAlphabet(length int, alphabet string) string

PseudorandomStringWithAlphabet generates a pseudorandom string with the specified length and characters set.

For a cryptographically random (but a little bit slower) use RandomStringWithAlphabet instead.

func RandomString

func RandomString(length int) string

RandomString generates a cryptographically random string with the specified length.

The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.

func RandomStringWithAlphabet

func RandomStringWithAlphabet(length int, alphabet string) string

RandomStringWithAlphabet generates a cryptographically random string with the specified length and characters set.

It panics if for some reason rand.Int returns a non-nil error.

func RemoveBlankStrings

func RemoveBlankStrings(s []string) []string

func RemoveDuplicates

func RemoveDuplicates(arr []string) []string

RemoveDuplicates removes the duplicates strings from a Slice

func RenderMustaches

func RenderMustaches(data string, dict map[string]interface{}, valueGetter ...func(k string, v interface{}) string) string

解析 Mustaches 语法 替换 {{ key }} 为 val

func SplitAndTrimSpace

func SplitAndTrimSpace(s string, sep string) []string

func StructToFlatDotMap

func StructToFlatDotMap(s interface{}) map[string]interface{}

func StructToMap

func StructToMap(s interface{}) map[string]interface{}

func ToString

func ToString(val interface{}) string

任何类型转 String

(bool) true => (string) "true"
(int) 0 => (string) "0"

func TruncateString

func TruncateString(str string, length int) string

func ValidateEmail

func ValidateEmail(email string) bool

func ValidateURL

func ValidateURL(url string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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