utils

package
v2.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 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 GetSha256Hash

func GetSha256Hash(text string) string

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(v 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