util

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeOut time.Duration = 60 * time.Second

TimeOut 全局请求超时设置,默认1分钟

Functions

func AesDecrypt

func AesDecrypt(src, key []byte) (dst []byte, err error)

AesDecrypt AES-CBC解密,PKCS#7,传入密文和密钥,[]byte

func AesEncrypt

func AesEncrypt(src []byte, key []byte) ([]byte, error)

AesEncrypt AES-CBC加密+PKCS#7打包,传入明文和密钥

func GetBody

func GetBody(uri string) ([]byte, error)

GetBody 发送GET请求,返回body字节

func GetFile

func GetFile(filename, uri string) error

GetFile 下载文件

func GetJson

func GetJson(uri string, v interface{}) error

GetJson 发送GET请求解析json

func GetRandomString added in v1.1.0

func GetRandomString(l int) string

GetRandomString 获得随机字符串

func GetXml

func GetXml(uri string, v interface{}) error

GetXml 发送GET请求并解析xml

func Min added in v1.1.0

func Min(first int, args ...int) int

Min golang min int

func PKCS7Pad

func PKCS7Pad(msg []byte, blockSize int) []byte

PKCS7Pad PKCS#7打包

func PKCS7UnPad

func PKCS7UnPad(msg []byte) []byte

PKCS7UnPad PKSC#7解包

func PostFile

func PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile 上传文件

func PostJson

func PostJson(uri string, obj interface{}) ([]byte, error)

PostJson 发送Json格式的POST请求

func PostJsonPtr

func PostJsonPtr(uri string, obj interface{}, result interface{}, contentType ...string) (err error)

PostJsonPtr 发送Json格式的POST请求并解析结果到result指针

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他表单数据

func PostXmlPtr

func PostXmlPtr(uri string, obj interface{}, result interface{}) (err error)

PostXmlPtr 发送Xml格式的POST请求并解析结果到result指针

func SetTimeOut

func SetTimeOut(d time.Duration)

SetTimeOut 设置全局请求超时

func SortMd5 added in v1.1.0

func SortMd5(s ...string) string

SortMd5 排序并md5,主要用于计算sign

func SortSha1 added in v1.1.0

func SortSha1(s ...string) string

SortSha1 排序并sha1,主要用于计算signature

func Substr added in v1.1.0

func Substr(str string, start int, end int) string

Substr 截取字符串 start 起点下标 end 终点下标(不包括)

Types

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField 文件或其他表单数据

Jump to

Keyboard shortcuts

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