toolkit

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

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorKeyLenInvalid = errors.New("length of key invalid")
View Source
var ErrorViLenInvalid = errors.New("length of iv invalid")

Functions

func CsvToStr2d

func CsvToStr2d(path string) ([][]string, error)

func Decrypt

func Decrypt(cipherText string, key string, iv string) (string, error)

Decrypt 解密

cipherText: 解密目标字符串 key: 加密Key, 16||24||32位 iv: 加密iv(AES时固定为16位)

func DeduplicateStrArrWithMap

func DeduplicateStrArrWithMap(arr []string) []string

字符串切片去重(用hashMap)

func Encrypt

func Encrypt(plainText string, key string, iv string) (string, error)

Encrypt 加密

plainText: 加密目标字符串 key: 加密Key, 16||24||32位 iv: 加密iv(AES时固定为16位)

func Get

func Get(getUrl string, timeout time.Duration) (httpStatusCode int, resBody string, err error)

get body from url if timeout==0,it means no timeout limit

func IndexStrArr

func IndexStrArr(s string, arr []string) int

IndexStrArr return the first index of string s found in arr; If not found ,return -1

func PostComplexDeliverV2

func PostComplexDeliverV2(postUrl string, mainJsonS CdMainJson, filePaths []string) (httpStatusCode int, resBody string, err error)

func PostForm

func PostForm(postUrl string, valMap map[string]string, fileMap map[string]string) (httpStatusCode int, resBody string, err error)

PostForm simulate the front-end initiating a form request; @param valMap map[string]string stores the form field name and form value. @param fileMap map[string]string stores the form field name and file path.

func SqlToStr2d

func SqlToStr2d(Db *gorm.DB, sql string, withHeader bool) (str2dP *[][]string, resErr error)

SqlToStr2d 执行sql,导出字符串二维数组,withHeader为true则str2d[1]为sql结果的列名 dsn := "user:pwd@tcp(192.168.1.173:3306)/dbName?charset=utf8&parseTime=True&loc=Local" db, err := gorm.Open(mysql.Open(dsn))

func Str3dToXlsx

func Str3dToXlsx(str3d [][][]string, dir string, fileName string) (realativeFilePath string, err error)

三维字符串数组转换为xlsx,错误则返回空路径和err

func StrArrEqual

func StrArrEqual(arr1 []string, arr2 []string) bool

字符串切片值是否相等

func StrArraysIntersect

func StrArraysIntersect(arr1 []string, arr2 []string) []string

字符串切片求交集

func StringPurgerForMatch

func StringPurgerForMatch(txt string) string

StringPurgerForMatch 去除标点空格,英文字母转为小写,中文数字转化为阿拉伯数字

func ToString

func ToString(any interface{}) string

func WechatStr2dTablizeRender

func WechatStr2dTablizeRender(str2d [][]string) (string, error)

(为微信)二维字符串数组对齐,不足补空格,默认第一行为表头; 如果str2d行宽度不一致,报错。

func XlsxToStr3d

func XlsxToStr3d(path string) ([][][]string, error)

Types

type CdFormItem

type CdFormItem struct {
	Raw      string     `json:"raw"`
	Img      string     `json:"img"`
	Tablize  [][]string `json:"tablize"`
	Excelize [][]string `json:"excelize"`
	File     string     `json:"file"`
}

type CdMainJson

type CdMainJson struct {
	Title      string       `json:"title"`
	GroupName  string       `json:"group_name"`
	MailDstTag string       `json:"mail_dst_tag"`
	MailDsts   string       `json:"mail_dsts"`
	FormItems  []CdFormItem `json:"form_items"`
}

Jump to

Keyboard shortcuts

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