goutil

package module
v0.0.0-...-5fac701 Latest Latest
Warning

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

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

README

golang 语言开发工具包

封装了类型转换、时间、字符串等方法。

  • 引用包:github.com/lalolv/goutil

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte, iv []byte) ([]byte, error)

AesDecrypt AES 解密 @origData 加密的原始数据 @key 密钥 @iv 向量

func AesEncrypt

func AesEncrypt(origData, key []byte, iv []byte) ([]byte, error)

AesEncrypt AES 加密 @origData 加密的原始数据 @key 密钥 @iv 向量

func Bool2Int

func Bool2Int(value bool) int

Bool2Int bool 转换为 int

func ByteFormat

func ByteFormat(size int64) string

ByteFormat returns a human-readable string representation of a byte count

func CheckPhone

func CheckPhone(tel string) bool

CheckPhone 检测手机号码

func Crmd5

func Crmd5(s string) string

Crmd5 MD5加密算法

func DurationFormat

func DurationFormat(ns int64) string

DurationFormat returns a human-readable string representation of nanosecond number

func EscapeQuots

func EscapeQuots(val string) string

EscapeQuots 转义引号 单引号和双引号

func FormatTime

func FormatTime(t time.Time) string

FormatTime 格式化时间格式,生成一个描述性的时间

func FormatTimeUnix

func FormatTimeUnix(t int64) string

FormatTimeUnix 格式化时间格式

func GetTimeByDuration

func GetTimeByDuration(days float64) time.Time

GetTimeByDuration 根据间隔获取指定时间

func GetTimeZero

func GetTimeZero(t time.Time) int64

GetTimeZero 获取指定日期的0点的时间

func InArray

func InArray(arrs []interface{}, value interface{}, equalMethod func(interface{}, interface{}) bool) bool

InArray 判断一个值是否存在于数组当中 @arrs 要判断的数组 @value 要判断的值

func InStringArray

func InStringArray(arrs []string, value string, equalMethod func(string, string) bool) bool

InStringArray 判断是否在String数组里面 @arrs @value

func IsEmpty

func IsEmpty(val string) bool

IsEmpty 利用正则表达式判断一个字符串是不是空 @val要判断的值

func JudgeSmallThenToday

func JudgeSmallThenToday(t int64) bool

JudgeSmallThenToday 判断是否为小于今天的时间 @time 要判断的时间

func Log

func Log(info interface{}, prefix string)

Log 创建日志文件 保存到当前目录下的 log 子目录中

func MD5

func MD5(data string) string

MD5 对字符串进行MD5哈希

func MonthCount

func MonthCount(year int, month int) (days int)

MonthCount 计算年月的天数 @year @month

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding PKCS5

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) ([]byte, error)

PKCS5UnPadding PKCS5

func PrecFloat64

func PrecFloat64(f float64, p int) float64

PrecFloat64 设置精度

func RandomFloat64

func RandomFloat64(min, max float64, p int) float64

RandomFloat64 随机生成64位小数 @min 最小值 @max 最大值 @p 小数精度

func RandomSpec

func RandomSpec(count uint, start, end int, letters, numbers bool, chars []rune) string

RandomSpec Creates a random string based on a variety of options, using supplied source of randomness.

If start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32.

If set is not nil, characters between start and end are chosen.

This method accepts a user-supplied rand.Rand instance to use as a source of randomness. By seeding a single rand.Rand instance with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably.

func RemoveDuplicatesInt64

func RemoveDuplicatesInt64(elements []int64) []int64

RemoveDuplicatesInt64 删除重复元素

func SHA1

func SHA1(data string) string

SHA1 对字符串进行SHA1哈希

func SendMail

func SendMail(mailInfo MailInfo)

SendMail 发送邮件 @mailInfo

func Str2Float

func Str2Float(s string) float64

Str2Float 字符串装换为浮点类型

func Str2Int

func Str2Int(s string) int

Str2Int 字符串装换为整数类型

func Str2Int64

func Str2Int64(s string) int64

Str2Int64 字符串装换为整数类型

func Str2Uint

func Str2Uint(s string) uint

Str2Uint 字符串装换为整数类型

func SubstrByByte

func SubstrByByte(str string, length int) string

SubstrByByte 按字节截取字符串 utf-8不乱码

func TinyNo

func TinyNo() string

TinyNo 短单号

func ToFloat32

func ToFloat32(value interface{}) (float32, error)

ToFloat32 转换为ToFloat32

func ToFloat64

func ToFloat64(value interface{}) (float64, error)

ToFloat64 转换为 float64

func ToInt

func ToInt(value interface{}) (int, error)

ToInt 转换为int类型

func ToInt32

func ToInt32(value interface{}) (int32, error)

ToInt32 转换为Int32

func ToInt64

func ToInt64(value interface{}) (int64, error)

ToInt64 转换为Int64

func ToString

func ToString(args ...interface{}) (string, error)

ToString args: value, precision(only for float)

func U82Str

func U82Str(value interface{}) string

U82Str uint8转换为str

func U8sFloat64

func U8sFloat64(value interface{}) float64

U8sFloat64 uint8 转换为 float64

func U8sInt

func U8sInt(value interface{}) int

U8sInt uint8 转换为 int

func WhenNil

func WhenNil(value interface{}, nilReturn interface{}, okReturn interface{}) interface{}

WhenNil 当空值(Map长度为0)的时候返回相应数据 @value 测试的值 @nilReturn 空值返回的值 @okReturn 不为空的时候返回的值

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) []byte

ZeroPadding 0padding

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

ZeroUnPadding 0padding

Types

type Dfa

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

Dfa DFA 算法

func (*Dfa) BuildTree

func (p *Dfa) BuildTree(words []string)

BuildTree 构建敏感词过滤器 @words 敏感词列表

func (*Dfa) FilterWords

func (p *Dfa) FilterWords(text, replaceChar string) (string, bool)

FilterWords 过滤关键词 @text 输入文本 @replaceChar 替换的字符

func (*Dfa) IsContain

func (p *Dfa) IsContain(text string) bool

IsContain 判断是否包含敏感词 @text 输入文本

func (*Dfa) IsTreeBuild

func (p *Dfa) IsTreeBuild() bool

IsTreeBuild 判断过滤的树是否已经生成了

func (*Dfa) RegularFilter

func (p *Dfa) RegularFilter(text string) (string, bool)

RegularFilter 正则过滤

type MailInfo

type MailInfo struct {
	SMTPHost   string
	SMTPPasswd string
	FromEmail  string
	FromName   string
	ToEmail    string
	ToName     string
	Subject    string
	Body       string
}

MailInfo 邮件

type Node

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

Node 结构

Jump to

Keyboard shortcuts

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