pubfunc

package
v0.0.0-...-2e4edee Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Insight 0+0各包共同使用的辅助函数

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteFile

func AbsoluteFile(file, abs string) (absolute string)

生成绝对文件路径,如果给定的path不是绝对路径(以/开头),则用给定的abs补充并返回绝对文件地址,否则直接返回file

func AbsolutePath

func AbsolutePath(path, abs string) (absolute string)

生成绝对路径,如果给定的path不是绝对路径(以/开头),则用给定的abs补充并返回绝对路径(以/结尾),否则直接返回path(并以/结尾)

func CommandSplit

func CommandSplit(command string, trim bool) (split []string, err error)

Split the string, if trim is true, the split with out space.

func DecodeSalt

func DecodeSalt(str, stream, salt string) string

DecodeSalt 解盐

func DirMustEnd

func DirMustEnd(dir string) string

判断目录名,如果不是“/”结尾就加上“/”

func EncodeSalt

func EncodeSalt(str, stream, salt string) string

EncodeSalt 加盐

func FileExist

func FileExist(filename string) bool

文件是否存在

func GetCurrPath

func GetCurrPath() string

返回执行文件的绝对路径

func IsOdd

func IsOdd(num int) bool

Is odd number

func LocalFile

func LocalFile(path string) string

处理给出的文件地址,如果为相对路径就加上绝对路径

func LocalPath

func LocalPath(path string) string

处理给出的路径地址,如果为相对路径就加上绝对路径

func PathMustBegin

func PathMustBegin(path string) string

路径必须以斜线开始

func SplitUrl

func SplitUrl(url string) (urla []string, parameter map[string]string)

将Url用斜线/拆分 :id=dfad/:type=dafa/

func SplitWords

func SplitWords(str string) (normal [][]string)

将提供的字符串进行拆分词语处理

func StringInSlice

func StringInSlice(list []string, s string) bool

Types

type InputProcessor

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

InputProcessor 输入处理器

func NewInputProcessor

func NewInputProcessor() (ip *InputProcessor)

创建输入处理

func (*InputProcessor) EditorIn

func (ip *InputProcessor) EditorIn(text string, cannull bool, min, max int64) (textc string, err int)

处理编辑器的输入,除了字数检测外,主要是过滤script标签

func (*InputProcessor) EditorRe

func (ip *InputProcessor) EditorRe(text string) string

处理编辑器的重新编辑

func (*InputProcessor) Email

func (ip *InputProcessor) Email(text string, cannull bool, min, max int64) (textc string, err int)

查看格式是不是邮箱地址

func (*InputProcessor) Enum

func (ip *InputProcessor) Enum(text string, cannull bool, enum []string) (textc string, err int)

枚举,判断提供的字符串是否出现在字符串切片里

func (*InputProcessor) Float

func (ip *InputProcessor) Float(text string, cannull bool, min, max float64) (num float64, err int)

输入是否为浮点

func (*InputProcessor) Int

func (ip *InputProcessor) Int(text string, cannull bool, min, max int64) (num int64, err int)

输入是否为整数

func (*InputProcessor) Mark

func (ip *InputProcessor) Mark(text string, cannull bool, min, max int64) (textc string, err int)

处理作为标记的的字符串,只能由字母数字和连字符组成

func (*InputProcessor) Password

func (ip *InputProcessor) Password(text string, cannull bool) (textc string, err int)

处理密码

func (*InputProcessor) PasswordTwo

func (ip *InputProcessor) PasswordTwo(text, text2 string, cannull bool) (textc string, err int)

查看两遍密码

func (*InputProcessor) Regular

func (ip *InputProcessor) Regular(text string, cannull bool, rg string) (textc string, err int)

正则判断,提供一个正则表达,如果匹配则返回字符串

func (*InputProcessor) StringEnum

func (ip *InputProcessor) StringEnum(text string, canull bool, enum []string) (textc string, err int)

字符串枚举

func (*InputProcessor) Text

func (ip *InputProcessor) Text(text string, cannull bool, min, max int64) (textc string, err int)

处理简单文本输入,替换可能引起注入的字符、判断长度等

func (*InputProcessor) TextareaOut

func (ip *InputProcessor) TextareaOut(text string, thetype bool) string

处理文本域的输出,主要就是对换行符进行处理,将\r\n之类的转换成<p>或<br>,thetype为true则转成<p>,type为false则转为<br>

func (*InputProcessor) Url

func (ip *InputProcessor) Url(text string, cannull bool, min, max int64) (textc string, err int)

处理连接,主要是如果没有协议的话,就加上http://

Jump to

Keyboard shortcuts

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