base

package module
v0.0.0-...-a913e03 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: LGPL-3.0 Imports: 15 Imported by: 4

README

Package base

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

Documentation

Overview

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

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

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

random包提供一套生成随机字符串的方法。 包括根据字符串生成sha1和sha256散列值,生成40位或成倍的Unid的方法。

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

文件是否存在,不存在的话,返回false

func GetCurrPath

func GetCurrPath() string

返回执行文件的绝对路径

func GetRand

func GetRand(len int) string

获取len长度随机字符串。

func GetRandNum

func GetRandNum(max int) int

获取不大于max的随机正整数。

func GetSha1Sum

func GetSha1Sum(text string) string

获取字符串的Sha1散列值。

func GetSha1SumBytes

func GetSha1SumBytes(b []byte) string

获取字节切片的Sha1散列值。

func GetSha256Sum

func GetSha256Sum(text string) string

func GetSha512Sum

func GetSha512Sum(text string) string

获取字符串的Sha512散列值。

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

Slice里是否包含String

func Unid

func Unid(length uint, text ...string) string

根据输入的text生成唯一ID。length最小需要为1,返回的字符串的长度为length*40个字符长,为length个sha1的值串联。

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