utils

package
v0.0.0-...-5387047 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CVtolocal *iconv.Converter
	CVtoutf8  *iconv.Converter
)

Functions

func BuildLongString

func BuildLongString(src []byte) []byte

BuildLongString 构建长字符串消息,包含2字节的字符串大小

func BuildString

func BuildString(src []byte) []byte

BuildString 构建长字符串消息,包含2字节的字符串大小

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

BytesCombine 连接字符串

func CheckErr

func CheckErr(err error)

CheckErr 有错误就显示

func CompareBytes

func CompareBytes(a []byte, b []byte) bool

CompareBytes 比较两个数组是否内容相等,相等返回true

func Convert9Uint16sToInt16s

func Convert9Uint16sToInt16s(src [9]uint16) []int16

func ConvertUint16sToInt16s

func ConvertUint16sToInt16s(src []uint16) []int16

func ConvertUint32sToInt32s

func ConvertUint32sToInt32s(src []uint32) []int32

func Convertint16sTo9Uint16s

func Convertint16sTo9Uint16s(src []int16) [9]uint16

func Convertint16sToUint16s

func Convertint16sToUint16s(src []int16) []uint16

func Convertint32sToUint32s

func Convertint32sToUint32s(src []int32) []uint32

func Decode

func Decode(data []byte, to interface{}) error

Decode 数组转结构体

func Encode

func Encode(data interface{}) ([]byte, error)

Encode 结构体转数组

func GetExePath

func GetExePath() (string, error)

GetExePath() 获取当前可执行文件所在目录

func GetIP

func GetIP() string

GetIP 获取IP

func GetUint16

func GetUint16(b []byte) uint16

GetUint16 获取b数组最前面的2字节数据

func GetUint16BE

func GetUint16BE(b []byte) uint16

GetUint16BE 获取b数组最前面的2字节数据,大端模式

func GetUint32

func GetUint32(b []byte) uint32

GetUint32 获取b数组最前面的4字节数据

func GetUint32BE

func GetUint32BE(b []byte) uint32

GetUint32BE 获取b数组最前面的4字节数据,大端模式

func GetUint64

func GetUint64(b []byte) uint64

GetUint64 获取b数组最前面的8字节数据

func GetUint64BE

func GetUint64BE(b []byte) uint64

GetUint64BE 获取b数组最前面的8字节数据,大端模式

func IPToUint32

func IPToUint32(s string) (uint32, error)

IPToUint32 把IP转换成4字节uint

func InitConverter

func InitConverter(local string) bool

func IntAbs

func IntAbs(num int) int

IntAbs 绝对值

func IsAllNumber

func IsAllNumber(str string) bool

func IsSameLan

func IsSameLan(a []byte, b []byte) bool

IsSameLan 判断两个IP是否处于同一局域网

func IsSameName

func IsSameName(dest, src []byte) bool

IsSameName 检查dest是否与src字符串像差不多

func LocalToUtf8

func LocalToUtf8(str string) (b string, err error)

func PasswordFilter

func PasswordFilter(str []byte) bool

func RandInt16

func RandInt16(min, max int16) int16

RandInt16 随机一个int32数字

func RandInt32

func RandInt32(min, max int32) int32

RandInt32 随机一个int32数字

func RandInt64

func RandInt64(min, max int64) int64

RandInt64 随机一个int64数字

func ReadString

func ReadString(b []byte, offset *int, len int) []byte

ReadString 大端不会读取长度,需要单独先读取长度

func ReadStringFromFile

func ReadStringFromFile(path string) string

func ReadStringToNULL

func ReadStringToNULL(b []byte, offset *int) string

ReadString 大端不会读取长度,需要单独先读取长度

func ReadUint16

func ReadUint16(b []byte, offset *int) uint16

ReadUint16 读取2字节到uint16

func ReadUint16BE

func ReadUint16BE(b []byte, offset *int) uint16

ReadUint16BE 大端读取2字节到uint16

func ReadUint32

func ReadUint32(b []byte, offset *int) uint32

ReadUint32 读取4字节到uint32

func ReadUint32Array

func ReadUint32Array(b []byte, offset *int, len int) []uint32

ReadUint32Array 读取数据到uint32数组

func ReadUint32BE

func ReadUint32BE(b []byte, offset *int) uint32

ReadUint32BE 大端读取4字节到uint32

func ReadUint64

func ReadUint64(b []byte, offset *int) uint64

ReadUint64 读取8字节到uint64

func ReadUint64BE

func ReadUint64BE(b []byte, offset *int) uint64

ReadUint64BE 大端读取8字节到uint64

func ReadUint8

func ReadUint8(b []byte, offset *int) uint8

ReadUint8 读取1字节到uint8

func ScanLine

func ScanLine() (line string)

ScanLine 得到一行

func SendEmailTO

func SendEmailTO(mail *EmailData) error

func SlideIP

func SlideIP(s string) int

SlideIP 切割IP,找到:位置

func Ternary

func Ternary(b bool, t, f interface{}) interface{}

Ternary 三目运算符

func Utf8ToLocal

func Utf8ToLocal(str string) (b string, err error)

func WriteLongString

func WriteLongString(dest *[]byte, src []byte, offset *int) int

WriteLongString 写入字符串,包括2字节长度

func WriteString

func WriteString(dest *[]byte, src []byte, offset *int) int

WriteString 写入字符串,包括长度

func WriteStringWithNull

func WriteStringWithNull(dest *[]byte, src []byte, offset *int) int

WriteString 写入字符串,不包括长度

func WriteUint16

func WriteUint16(b *[]byte, i uint16, offset *int)

WriteUint16 写入2字节uint16

func WriteUint16BE

func WriteUint16BE(b *[]byte, i uint16, offset *int)

WriteUint16BE 写入2字节uint16,大端模式

func WriteUint32

func WriteUint32(b *[]byte, i uint32, offset *int)

WriteUint32 写入4字节uint32

func WriteUint32Array

func WriteUint32Array(b *[]byte, a []uint32, offset *int)

WriteUint32Array 写入uint32数组

func WriteUint32BE

func WriteUint32BE(b *[]byte, i uint32, offset *int)

WriteUint32BE 写入4字节uint32,大端模式

func WriteUint64

func WriteUint64(b *[]byte, i uint64, offset *int)

WriteUint64 写入8字节uint64

func WriteUint64BE

func WriteUint64BE(b *[]byte, i uint64, offset *int)

WriteUint64BE 写入8字节uint64,大端模式

func WriteUint8

func WriteUint8(b *[]byte, i uint8, offset *int)

WriteUint8 写入1字节uint8

Types

type BloomFilter

type BloomFilter struct {
	Size  uint
	Set   *bitset.BitSet
	Funcs []SimpleHash
}

func NewBloomFilter

func NewBloomFilter(size uint, seeds []uint) *BloomFilter

NewBloomFilter 新建一个bloomfilter

func (BloomFilter) Add

func (bf BloomFilter) Add(value string)

Add 添加一个数据

func (BloomFilter) Contains

func (bf BloomFilter) Contains(value string) bool

Contains 是否可能存在

type EmailData

type EmailData struct {
	SenderMail    string
	SenderCode    string
	SenderSMTP    string
	TargetMail    string
	MailSubHeader string
	MailHeader    string
	Content       string
}

type IniParser

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

func (*IniParser) IniGetFloat32

func (this *IniParser) IniGetFloat32(section string, key string) float32

func (*IniParser) IniGetFloat64

func (this *IniParser) IniGetFloat64(section string, key string) float64

func (*IniParser) IniGetInt32

func (this *IniParser) IniGetInt32(section string, key string) int32

func (*IniParser) IniGetInt64

func (this *IniParser) IniGetInt64(section string, key string) int64

func (*IniParser) IniGetString

func (this *IniParser) IniGetString(section string, key string) string

func (*IniParser) IniGetUint32

func (this *IniParser) IniGetUint32(section string, key string) uint32

func (*IniParser) IniGetUint64

func (this *IniParser) IniGetUint64(section string, key string) uint64

func (*IniParser) LoadIni

func (this *IniParser) LoadIni(config_file_name string) error

type IniParserError

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

func (*IniParserError) Error

func (e *IniParserError) Error() string

type SimpleHash

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

func (SimpleHash) Hash

func (s SimpleHash) Hash(value string) uint

Jump to

Keyboard shortcuts

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