utils

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: GPL-3.0 Imports: 10 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParseUnicode = StringFilterFunc(func(str string) string {
	buf := new(bytes.Buffer)
	chars := []byte(str)
	for i := 0; i < len(str); {
		if chars[i] == 92 && chars[i+1] == 117 {
			t, _ := strconv.ParseInt(string(chars[i+2:i+6]), 16, 32)
			buf.WriteString(fmt.Sprintf("%c", t))
			i += 6
		} else {
			buf.WriteByte(chars[i])
			i++
		}
	}
	return buf.String()
})
View Source
var ReplaceIllegalChar = StringFilterFunc(func(str string) string {
	reg := regexp.MustCompile(`[\/\\\:\*\?\"\<\>\|]`)
	return reg.ReplaceAllString(str, "_")
})
View Source
var UnescapeHTMLEntity = StringFilterFunc(html.UnescapeString)

Functions

func GenRandomName

func GenRandomName(n int) string

func GenUrls

func GenUrls(strs ...string) ([]*url.URL, error)

func GetMd5String

func GetMd5String(b []byte) string

func IsFFmpegExist

func IsFFmpegExist() bool

func Match1

func Match1(re, str string) string

func ParseString

func ParseString(str string, filter ...StringFilter) string

Types

type StringFilter

type StringFilter interface {
	Do(string) string
}

type StringFilterChain

type StringFilterChain struct {
	// contains filtered or unexported fields
}

func NewStringFilterChain

func NewStringFilterChain(filter ...StringFilter) *StringFilterChain

func (*StringFilterChain) Do

func (c *StringFilterChain) Do(str string) string

type StringFilterFunc

type StringFilterFunc func(string) string

func (StringFilterFunc) Do

func (f StringFilterFunc) Do(s string) string

Jump to

Keyboard shortcuts

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