gnomon

package module
v0.0.0-...-8f0e436 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 58 Imported by: 27

README

Release GoDoc Go Report Card GolangCI Codacy Badge Travis (.org) Coveralls github

Gnomon

通用编写go应用的公共库。

开发环境

  • Go 1.12+
  • Darwin/amd64

测试环境

  • Go 1.11+
  • Linux/x64
安装

go get github.com/aberic/gnomon

使用工具
gnomon.Byte… // 字节
gnomon.Command… // 命令行
gnomon.Env… // 环境变量
gnomon.File… // 文件操作
gnomon.IP… // IP
gnomon.JWT… // JWT
gnomon.String… // 字符串
gnomon.Hash… // Hash/散列
gnomon.RSA… // RSA
gnomon.ECC… // ECC
gnomon.AES… // AES
gnomon.DES… // DES
gnomon.CA… // CA
gnomon.Scale… // 算数/转换
gnomon.Time… // 时间
gnomon.Pool… // conn池
gnomon.GRPC… // grpc请求
gnomon.HTTP… // http请求
使用HTTP Server
func main() {
	httpServe := grope.NewHTTPServe(doFilter)
	router(httpServe)
	grope.ListenAndServe(":8888", httpServe)
}

func doFilter(ctx *grope.Context) {
	if ctx.HeaderGet("name") != "name" {
		log.Info("doFilter1", log.Field("resp", ctx.ResponseText(http.StatusForbidden, "filter name")))
	}
}

func router(hs *grope.GHttpServe) {
	// 仓库相关路由设置
	route := hs.Group("/one/test")
	route.Post("/test1", one1)
	route.Put("/test1", one2)
	route.Post("/test2/:a/:b", one2)
	route.Post("/test3/:a/:b", one3)
	route.Post("/test4/:a/:b", one4)
	route.Post("/test5/:a/:b", one5)
	route.Put("/test6/ok", one1)
	route.Put("/test6/ok/no", one6)
	route.Put("/test6/:a/:b", one6)
}


func one1(ctx *grope.Context) {
	ones := &TestOne{}
	_ = ctx.ReceiveJSON(ones)
	log.Info("one", log.Field("one", &ones),
		log.Field("url", ctx.Request().URL.String()), log.Field("paramMap", ctx.Params()))
	log.Info("one1", log.Field("resp", ctx.ResponseJSON(http.StatusOK, &TestTwo{
		Two:   "1",
		Twos:  false,
		TwoGo: 1,
	})))
}

……

更多详情参考:https://github.com/aberic/gnomon/blob/master/example/grope/grope_example.go

使用MySQL
func SQL() {
	sql = &db.MySQL{}
	_ = sql.Connect(dbURL, dbUser, dbPass, dbName, false, 5, 20)
	row := sql.DB.Raw("select * from table where id=?", id).Row()
}

更多详情参考:https://github.com/aberic/gnomon/blob/master/example/sql/init.go

使用log
func LogDebug() {
	log.Set(log.DebugLevel(), "tmp/log", 1, 1, false, false)
	log.Debug("test", log.Field("1", "2"), log.Field("2", 3), log.Field("3", true))
	log.Debug("test", nil)
	log.Info("test", log.Field("1", "2"), log.Field("2", 3), log.Field("3", true))
	log.Warn("test", log.Field("1", "2"), log.Field("2", 3), log.Field("3", true))
	log.Error("test", log.Field("1", "2"), log.Field("2", 3), log.Field("3", true), log.Err(errors.New("yes")))
}

更多详情参考:https://github.com/aberic/gnomon/blob/master/example/log/log_test.go

使用Balance
func TestNewBalanceWeightRandom(t *testing.T) {
	b := NewBalance(Random)
	b.Add(1)
	b.Weight(1, 10)
	b.Add(2)
	b.Weight(2, 5)
	b.Add(3)
	b.Weight(3, 1)
	for i := 0; i < 50; i++ {
		t.Log(b.Acquire())
	}
}

更多详情参考:https://github.com/aberic/gnomon/blob/master/balance/balance_test.go

文档

参考 https://godoc.org/github.com/aberic/gnomon



Documentation

Overview

Package gnomon 是一个编写go应用或软件可选的公共库

目前提供的方法包如下:

gnomon.Byte… // 字节

gnomon.Command… // 命令行

gnomon.Env… // 环境变量

gnomon.File… // 文件操作

gnomon.IP… // IP

gnomon.JWT… // JWT

gnomon.String… // 字符串

gnomon.CryptoHash… // Hash/散列

gnomon.CryptoRSA… // RSA

gnomon.CryptoECC… // ECC

gnomon.CryptoAES… // AES

gnomon.CryptoDES… // DES

gnomon.CA… // CA

gnomon.Log… // 日志

gnomon.Scale… // 算数/转换

gnomon.Time… // 时间

SQLCommon sql 连接对象

Pool io.Closer连接池工具

gnomon.HTTPClientCommon http客户端工具

未来会陆续添加新的方法或类型,对于已经编写的内容会尽量覆盖其测试范围。如果有新的需求可以提出,以便后续加进去,或直接提交代码对该库进行补充

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecryptCBC

func AESDecryptCBC(encrypted []byte, key []byte) []byte

AESDecryptCBC AES CBC模式解密

func AESDecryptCFB

func AESDecryptCFB(encrypted []byte, key []byte) (decrypted []byte)

AESDecryptCFB AES CFB模式解密

func AESDecryptECB

func AESDecryptECB(encrypted []byte, key []byte) (decrypted []byte)

AESDecryptECB AES ECB模式解密

func AESDecryptOFB

func AESDecryptOFB(encrypted []byte, key []byte) (decrypted []byte)

AESDecryptOFB AES OFB模式解密

func AESEncryptCBC

func AESEncryptCBC(data []byte, key []byte) (encrypted []byte)

AESEncryptCBC AES CBC模式加密

func AESEncryptCFB

func AESEncryptCFB(data []byte, key []byte) (encrypted []byte)

AESEncryptCFB AES CFB模式加密

func AESEncryptECB

func AESEncryptECB(data []byte, key []byte) (encrypted []byte)

AESEncryptECB AES ECB模式加密

func AESEncryptOFB

func AESEncryptOFB(data []byte, key []byte) (encrypted []byte)

AESEncryptOFB AES OFB模式加密

func BytesToInt

func BytesToInt(byte []byte) (int, error)

BytesToInt 字节转换成int

func BytesToUint16

func BytesToUint16(buf []byte) uint16

BytesToUint16 字节转换成uint16

func BytesToUint32

func BytesToUint32(buf []byte) uint32

BytesToUint32 字节转换成uint32

func BytesToUint64

func BytesToUint64(buf []byte) uint64

BytesToUint64 字节转换成uint64

func CAGenerateCertificate

func CAGenerateCertificate(cert *Cert) (certData []byte, err error)

CAGenerateCertificate 对签名请求进行处理并生成签名数字证书

cert 签名数字证书对象

func CAGenerateCertificateRequest

func CAGenerateCertificateRequest(cert *CertRequestModel) (csr []byte, err error)

CAGenerateCertificateRequest 生成证书签名请求文件

cert 证书生成请求对象

func CAGenerateCertificateSelf

func CAGenerateCertificateSelf(cert *CertSelf) (certData []byte, err error)

CAGenerateCertificateSelf 对签名请求进行处理并生成自签名数字证书

cert 签名数字证书对象

func CAGenerateECCCertificateRequest

func CAGenerateECCCertificateRequest(cert *CertRequest, pemType string) (csr []byte, err error)

CAGenerateECCCertificateRequest 生成证书签名请求文件

cert 证书生成请求对象

func CAGenerateECCCertificateRequestFP

func CAGenerateECCCertificateRequestFP(cert *CertRequestFP, pemType string) (csr []byte, err error)

CAGenerateECCCertificateRequestFP 生成证书签名请求文件

cert 证书生成请求对象

func CAGenerateECCCertificateRequestFPWithPass

func CAGenerateECCCertificateRequestFPWithPass(cert *CertRequestFP, password, pemType string) (csr []byte, err error)

CAGenerateECCCertificateRequestFPWithPass 生成证书签名请求文件

cert 证书生成请求对象

password 生成时输入的密码

func CAGenerateECCCertificateRequestWithPass

func CAGenerateECCCertificateRequestWithPass(cert *CertRequest, password, pemType string) (csr []byte, err error)

CAGenerateECCCertificateRequestWithPass 生成证书签名请求文件

cert 证书生成请求对象

password 生成时输入的密码

func CAGenerateRSACertificateRequest

func CAGenerateRSACertificateRequest(cert *CertRequest, pemType string, pks PKSCType) (csr []byte, err error)

CAGenerateRSACertificateRequest 生成证书签名请求文件

cert 证书生成请求对象

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘RSAPKSC1()’和‘RSAPKSC8()’方法赋值

func CAGenerateRSACertificateRequestFP

func CAGenerateRSACertificateRequestFP(cert *CertRequestFP, pemType string, pks PKSCType) (csr []byte, err error)

CAGenerateRSACertificateRequestFP 生成证书签名请求文件

cert 证书生成请求对象

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘RSAPKSC1()’和‘RSAPKSC8()’方法赋值

func CAGenerateRSACertificateRequestFPWithPass

func CAGenerateRSACertificateRequestFPWithPass(cert *CertRequestFP, password, pemType string, pks PKSCType) (csr []byte, err error)

CAGenerateRSACertificateRequestFPWithPass 生成证书签名请求文件

cert 证书生成请求对象

password 生成时输入的密码

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘RSAPKSC1()’和‘RSAPKSC8()’方法赋值

func CAGenerateRSACertificateRequestWithPass

func CAGenerateRSACertificateRequestWithPass(cert *CertRequest, password, pemType string, pks PKSCType) (csr []byte, err error)

CAGenerateRSACertificateRequestWithPass 生成证书签名请求文件

cert 证书生成请求对象

password 生成时输入的密码

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘RSAPKSC1()’和‘RSAPKSC8()’方法赋值

func CALoadCrtFromFP

func CALoadCrtFromFP(crtFilePath string) (certificate *x509.Certificate, err error)

CALoadCrtFromFP 从文件中加载Crt对象

func CALoadCsrPemFromFP

func CALoadCsrPemFromFP(csrFilePath string) (cert *x509.CertificateRequest, err error)

CALoadCsrPemFromFP 从文件中读取csr信息

func CommandExec

func CommandExec(commandName string, params ...string) (line int, cmd *exec.Cmd, contentArray []string, err error)

CommandExec 执行cmd命令

commandName 命令执行文件名

命令后续参数以字符串数组的方式传入

line 执行命令后输出总行数

cmd cmd对象

contentArray 执行命令后输出内容按行放入字符串数组

func CommandExecAsync

func CommandExecAsync(commandAsync chan *CommandAsync, commandName string, params ...string)

CommandExecAsync 异步执行cmd命令

commandAsync CommandAsync通道对象

commandName 命令执行文件名

命令后续参数以字符串数组的方式传入

func CommandExecSilent

func CommandExecSilent(commandName string, params ...string) (line int, cmd *exec.Cmd, contentArray []string, err error)

CommandExecSilent 执行cmd命令

commandName 命令执行文件名

命令后续参数以字符串数组的方式传入

line 执行命令后输出总行数

cmd cmd对象

contentArray 执行命令后输出内容按行放入字符串数组

func CommandExecTail

func CommandExecTail(commandName string, params ...string) (line int, cmd *exec.Cmd, contentArray []string, err error)

CommandExecTail 实时打印执行脚本过程中的命令

命令后续参数以字符串数组的方式传入

line 执行命令后输出总行数

cmd cmd对象

contentArray 执行命令后输出内容按行放入字符串数组

func DESDecryptCBC

func DESDecryptCBC(data, key []byte) []byte

DESDecryptCBC CBC解密

data 待加密数据

key 自定义密钥,如:'[]byte("12345678")',长度必须是8位

func DESDecryptECB

func DESDecryptECB(data, key []byte) []byte

DESDecryptECB ECB解密

data 待加密数据

key 自定义密钥,如:'[]byte("12345678")',长度必须是8位

func DESEncryptCBC

func DESEncryptCBC(data, key []byte) []byte

DESEncryptCBC CBC加密

data 待加密数据

key 自定义密钥,如:'[]byte("12345678")',长度必须是8位

func DESEncryptECB

func DESEncryptECB(data, key []byte) []byte

DESEncryptECB ECB加密

data 待加密数据

key 自定义密钥,如:'[]byte("12345678")',长度必须是8位

func ECCBytes2PriKey

func ECCBytes2PriKey(data []byte, curve elliptic.Curve) *ecdsa.PrivateKey

ECCBytes2PriKey []byte转私钥

func ECCBytes2PubKey

func ECCBytes2PubKey(data []byte, curve elliptic.Curve) (*ecdsa.PublicKey, error)

ECCBytes2PubKey []byte转公钥

func ECCDecrypt

func ECCDecrypt(data []byte, privateKey *ecies.PrivateKey) ([]byte, error)

ECCDecrypt 解密

func ECCEncrypt

func ECCEncrypt(data []byte, publicKey *ecies.PublicKey) ([]byte, error)

ECCEncrypt 加密

func ECCGenerate

func ECCGenerate(curve elliptic.Curve) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)

ECCGenerate 生成公私钥对

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGenerateKey

func ECCGenerateKey(path, priFileName, pubFileName string, curve elliptic.Curve) error

ECCGenerateKey 生成公私钥对

path 指定公私钥所在生成目录

priFileName 指定生成的密钥名称

pubFileName 指定生成的密钥名称

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemBytes

func ECCGeneratePemBytes(priPemType, pubPemType, passwd string, curve elliptic.Curve) (priBytes, pubBytes []byte, err error)

ECCGeneratePemBytes 生成公私钥对

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemKey

func ECCGeneratePemKey(path, priFileName, pubFileName, priPemType, pubPemType string, curve elliptic.Curve) error

ECCGeneratePemKey 生成公私钥对

path 指定公私钥所在生成目录

priFileName 指定生成的密钥名称

pubFileName 指定生成的密钥名称

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemKeyWithPass

func ECCGeneratePemKeyWithPass(path, priFileName, pubFileName, passwd, priPemType, pubPemType string, curve elliptic.Curve) error

ECCGeneratePemKeyWithPass 生成公私钥对

path 指定公私钥所在生成目录

priFileName 指定生成的密钥名称

pubFileName 指定生成的密钥名称

passwd 生成密码

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemPriKey

func ECCGeneratePemPriKey(path, priFileName, pemType string, curve elliptic.Curve) error

ECCGeneratePemPriKey 生成私钥

path 指定私钥所在生成目录

priFileName 指定生成的密钥名称

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemPriKeyWithPass

func ECCGeneratePemPriKeyWithPass(path, priFileName, passwd, pemType string, curve elliptic.Curve) error

ECCGeneratePemPriKeyWithPass 生成私钥

path 指定私钥所在生成目录

priFileName 指定生成的密钥名称

passwd 生成时输入的密码

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePemPubKey

func ECCGeneratePemPubKey(privateKey *ecdsa.PrivateKey, path, pubFileName, pemType string) error

ECCGeneratePemPubKey 生成公钥

path 指定公钥所在生成目录

func ECCGeneratePriKey

func ECCGeneratePriKey(path, priFileName string, curve elliptic.Curve) error

ECCGeneratePriKey 生成私钥

path 指定私钥所在生成目录

priFileName 指定生成的密钥名称

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCGeneratePubKey

func ECCGeneratePubKey(privateKey *ecdsa.PrivateKey, path, pubFileName string, curve elliptic.Curve) error

ECCGeneratePubKey 生成公钥

path 指定公钥所在生成目录

func ECCLoadPri

func ECCLoadPri(file string, curve elliptic.Curve) (*ecdsa.PrivateKey, error)

ECCLoadPri 从文件中加载私钥

file 文件路径

func ECCLoadPriPem

func ECCLoadPriPem(privateKey []byte, pemType string) (*ecdsa.PrivateKey, error)

ECCLoadPriPem 解析私钥

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

func ECCLoadPriPemFP

func ECCLoadPriPemFP(file, pemType string) (*ecdsa.PrivateKey, error)

ECCLoadPriPemFP 从文件中加载私钥

file 文件路径

func ECCLoadPriPemFPWithPass

func ECCLoadPriPemFPWithPass(file, passwd, pemType string) (*ecdsa.PrivateKey, error)

ECCLoadPriPemFPWithPass 从文件中加载私钥

file 文件路径

passwd 生成privateKey时输入密码

func ECCLoadPriPemWithPass

func ECCLoadPriPemWithPass(privateKey []byte, passwd, pemType string) (*ecdsa.PrivateKey, error)

ECCLoadPriPemWithPass 解析私钥

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

passwd 生成privateKey时输入密码

func ECCLoadPub

func ECCLoadPub(file string, curve elliptic.Curve) (*ecdsa.PublicKey, error)

ECCLoadPub 从文件中加载公钥

file 文件路径

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCLoadPubPem

func ECCLoadPubPem(publicKey []byte, pemType string) (*ecdsa.PublicKey, error)

ECCLoadPubPem 从文件中加载公钥

file 文件路径

func ECCLoadPubPemFP

func ECCLoadPubPemFP(file, pemType string) (*ecdsa.PublicKey, error)

ECCLoadPubPemFP 从文件中加载公钥

file 文件路径

func ECCPri2PemBytes

func ECCPri2PemBytes(priPemType, passwd string, privateKey *ecdsa.PrivateKey) (data []byte, err error)

ECCPri2PemBytes ECCPri2PemBytes

func ECCPriKey2Bytes

func ECCPriKey2Bytes(privateKey *ecdsa.PrivateKey) []byte

ECCPriKey2Bytes 私钥转[]byte

func ECCPub2PemBytes

func ECCPub2PemBytes(pubPemType string, publicKey *ecdsa.PublicKey) (data []byte, err error)

ECCPub2PemBytes ECCPub2PemBytes

func ECCPubKey2Bytes

func ECCPubKey2Bytes(publicKey *ecdsa.PublicKey, curve elliptic.Curve) []byte

ECCPubKey2Bytes 公钥转[]byte

pub 公钥

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCSavePri

func ECCSavePri(file string, privateKey *ecdsa.PrivateKey) error

ECCSavePri 将私钥保存到给定文件,密钥数据保存为hex编码

func ECCSavePriPem

func ECCSavePriPem(privateKey *ecdsa.PrivateKey, path, fileName, pemType string) error

ECCSavePriPem 将私钥保存到给定文件

func ECCSavePriPemWithPass

func ECCSavePriPemWithPass(privateKey *ecdsa.PrivateKey, passwd, path, fileName, pemType string) error

ECCSavePriPemWithPass 将私钥保存到给定文件

func ECCSavePub

func ECCSavePub(file string, publicKey *ecdsa.PublicKey, curve elliptic.Curve) error

ECCSavePub 将公钥保存到给定文件,密钥数据保存为hex编码

file 文件路径

curve 曲线生成类型,如 crypto.S256()/elliptic.P256()/elliptic.P384()/elliptic.P512()

func ECCSavePubPem

func ECCSavePubPem(file, pemType string, publicKey *ecdsa.PublicKey) error

ECCSavePubPem 将公钥保存到给定文件

file 文件路径

func ECCSign

func ECCSign(privateKey *ecdsa.PrivateKey, data []byte) (sign []byte, err error)

ECCSign 签名

func ECCVerify

func ECCVerify(publicKey *ecdsa.PublicKey, data, sign []byte) (bool, error)

ECCVerify 验签

func EnvGet

func EnvGet(envName string) string

EnvGet 获取环境变量 envName 的值

envName 环境变量名称

func EnvGetBool

func EnvGetBool(envName string) bool

EnvGetBool 获取环境变量 envName 的 bool 值

envName 环境变量名称

func EnvGetD

func EnvGetD(envName string, defaultValue string) string

EnvGetD 获取环境变量 envName 的值

envName 环境变量名称

defaultValue 环境变量为空时的默认值

func EnvGetFloat64

func EnvGetFloat64(envName string) (float64, error)

EnvGetFloat64 获取环境变量 envName 的值

envName 环境变量名称

func EnvGetFloat64D

func EnvGetFloat64D(envName string, defaultValue float64) float64

EnvGetFloat64D 获取环境变量 envName 的值

envName 环境变量名称

defaultValue 环境变量为空时的默认值

func EnvGetInt

func EnvGetInt(envName string) (int, error)

EnvGetInt 获取环境变量 envName 的值

envName 环境变量名称

func EnvGetInt64

func EnvGetInt64(envName string) (int64, error)

EnvGetInt64 获取环境变量 envName 的值

envName 环境变量名称

func EnvGetInt64D

func EnvGetInt64D(envName string, defaultValue int64) int64

EnvGetInt64D 获取环境变量 envName 的值

envName 环境变量名称

defaultValue 环境变量为空时的默认值

func EnvGetIntD

func EnvGetIntD(envName string, defaultValue int) int

EnvGetIntD 获取环境变量 envName 的值

envName 环境变量名称

defaultValue 环境变量为空时的默认值

func EnvGetUint64

func EnvGetUint64(envName string) (uint64, error)

EnvGetUint64 获取环境变量 envName 的值

envName 环境变量名称

func EnvGetUint64D

func EnvGetUint64D(envName string, defaultValue uint64) uint64

EnvGetUint64D 获取环境变量 envName 的值

envName 环境变量名称

defaultValue 环境变量为空时的默认值

func FileAppend

func FileAppend(filePath string, data []byte, force bool) (int, error)

FileAppend 追加内容到文件中

filePath 文件地址

data 内容

force 如果文件已存在,会将文件清空

It returns the number of bytes written and an error

func FileCompressTar

func FileCompressTar(files []*os.File, dest string) error

FileCompressTar 压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func FileCompressZip

func FileCompressZip(files []*os.File, dest string) error

FileCompressZip 压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func FileCopy

func FileCopy(srcFilePath, dstFilePath string) (written int64, err error)

FileCopy 拷贝文件

srcFilePath 源文件路径

dstFilePath 目标文件路径

func FileDeCompressZip

func FileDeCompressZip(zipFile, dest string) error

FileDeCompressZip 解压

func FileLoopDirs

func FileLoopDirs(pathname string) ([]string, error)

FileLoopDirs 遍历文件夹下的所有子文件夹

func FileLoopFileNames

func FileLoopFileNames(pathname string) ([]string, error)

FileLoopFileNames 遍历文件夹及子文件夹下的所有文件名

func FileLoopFiles

func FileLoopFiles(pathname string) ([]string, error)

FileLoopFiles 遍历文件夹及子文件夹下的所有文件

func FileLoopOneDirs

func FileLoopOneDirs(pathname string) ([]string, error)

FileLoopOneDirs 遍历文件夹下一层的所有子文件夹

func FileModify

func FileModify(filePath string, offset int64, data []byte, force bool) (int, error)

FileModify 修改文件中指定位置的内容

filePath 文件地址

offset 以0为起始坐标的偏移量

data 内容

force 如果文件已存在,会将文件清空

It returns the number of bytes written and an error

func FileParentPath

func FileParentPath(filePath string) string

FileParentPath 文件父路径

func FilePathExists

func FilePathExists(path string) bool

FilePathExists 判断路径是否存在

func FileReadFirstLine

func FileReadFirstLine(filePath string) (string, error)

FileReadFirstLine 从文件中读取第一行并返回字符串数组

func FileReadLines

func FileReadLines(filePath string) ([]string, error)

FileReadLines 从文件中逐行读取并返回字符串数组

func FileReadPointLine

func FileReadPointLine(filePath string, line int) (string, error)

FileReadPointLine 从文件中读取指定行并返回字符串数组

func GRPCGetClientIP

func GRPCGetClientIP(ctx context.Context) (address string, port int, err error)

GRPCGetClientIP 取出gRPC客户端的ip地址和端口号

string form of address (for example, "192.0.2.1:25", "[2001:db8::1]:80")

func GRPCRequest

func GRPCRequest(url string, business Business) (interface{}, error)

GRPCRequest RPC 通过rpc进行通信 protoc --go_out=plugins=grpc:. grpc/proto/*.proto

func GRPCRequestPool

func GRPCRequestPool(pool *Pond, business Business) (interface{}, error)

GRPCRequestPool 通过rpc进行通信 protoc --go_out=plugins=grpc:. grpc/proto/*.proto

func GRPCRequestPools

func GRPCRequestPools(url string, business Business) (interface{}, error)

GRPCRequestPools 通过rpc进行通信 protoc --go_out=plugins=grpc:. grpc/proto/*.proto

func GRPCRequestSingleConn

func GRPCRequestSingleConn(url string, business Business) (interface{}, error)

GRPCRequestSingleConn RPC 通过rpc进行通信 protoc --go_out=plugins=grpc:. grpc/proto/*.proto

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

GetBytes 获取接口字节数组

func HTTPDelete

func HTTPDelete(url string) (resp *http.Response, err error)

HTTPDelete delete 请求

func HTTPDeleteJSON

func HTTPDeleteJSON(url string, model interface{}) (resp *http.Response, err error)

HTTPDeleteJSON delete 请求

func HTTPDeleteJSONTLS

func HTTPDeleteJSONTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteJSONTLS delete tls 请求

func HTTPDeleteJSONTLSBytes

func HTTPDeleteJSONTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteJSONTLSBytes delete tls 请求

func HTTPDeleteMsgPack

func HTTPDeleteMsgPack(url string, model interface{}) (resp *http.Response, err error)

HTTPDeleteMsgPack delete 请求

func HTTPDeleteMsgPackTLS

func HTTPDeleteMsgPackTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteMsgPackTLS delete tls 请求

func HTTPDeleteMsgPackTLSBytes

func HTTPDeleteMsgPackTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteMsgPackTLSBytes delete tls 请求

func HTTPDeleteProtoBuf

func HTTPDeleteProtoBuf(url string, pm proto.Message) (resp *http.Response, err error)

HTTPDeleteProtoBuf delete 请求

func HTTPDeleteProtoBufTLS

func HTTPDeleteProtoBufTLS(url string, pm proto.Message, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteProtoBufTLS delete tls 请求

func HTTPDeleteProtoBufTLSBytes

func HTTPDeleteProtoBufTLSBytes(url string, pm proto.Message, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteProtoBufTLSBytes delete tls 请求

content-type=application/x-protobuf

func HTTPDeleteTLS

func HTTPDeleteTLS(url string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteTLS delete tls 请求

func HTTPDeleteTLSBytes

func HTTPDeleteTLSBytes(url string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteTLSBytes delete tls 请求

func HTTPDeleteXML

func HTTPDeleteXML(url string, model interface{}) (resp *http.Response, err error)

HTTPDeleteXML delete 请求

func HTTPDeleteXMLTLS

func HTTPDeleteXMLTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteXMLTLS delete tls 请求

func HTTPDeleteXMLTLSBytes

func HTTPDeleteXMLTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteXMLTLSBytes delete tls 请求

func HTTPDeleteYaml

func HTTPDeleteYaml(url string, model interface{}) (resp *http.Response, err error)

HTTPDeleteYaml delete 请求

func HTTPDeleteYamlTLS

func HTTPDeleteYamlTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDeleteYamlTLS delete tls 请求

func HTTPDeleteYamlTLSBytes

func HTTPDeleteYamlTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDeleteYamlTLSBytes delete tls 请求

func HTTPDo

func HTTPDo(req *http.Request) (resp *http.Response, err error)

HTTPDo 自定义请求处理

func HTTPDoTLS

func HTTPDoTLS(req *http.Request, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPDoTLS 处理 tls 请求

func HTTPDoTLSBytes

func HTTPDoTLSBytes(req *http.Request, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPDoTLSBytes 处理 tls 请求

func HTTPGet

func HTTPGet(url string) (resp *http.Response, err error)

HTTPGet get 请求

func HTTPGetHostTLSBytes

func HTTPGetHostTLSBytes(url, host string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPGetHostTLSBytes get tls 请求

func HTTPGetTLS

func HTTPGetTLS(url string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPGetTLS get tls 请求

func HTTPGetTLSBytes

func HTTPGetTLSBytes(url string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPGetTLSBytes get tls 请求

func HTTPPatchForm

func HTTPPatchForm(url string, paramMap map[string]string) (resp *http.Response, err error)

HTTPPatchForm patch 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchFormMultipart

func HTTPPatchFormMultipart(url string, paramMap map[string]string, fileMap map[string]string) (resp *http.Response, err error)

HTTPPatchFormMultipart patch 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchFormMultipartTLS

func HTTPPatchFormMultipartTLS(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchFormMultipartTLS patch tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchFormMultipartTLSBytes

func HTTPPatchFormMultipartTLSBytes(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchFormMultipartTLSBytes patch tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchFormTLS

func HTTPPatchFormTLS(url string, paramMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchFormTLS patch tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchFormTLSBytes

func HTTPPatchFormTLSBytes(url string, paramMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchFormTLSBytes patch tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPatchJSON

func HTTPPatchJSON(url string, model interface{}) (resp *http.Response, err error)

HTTPPatchJSON patch 请求

content-type=application/json

func HTTPPatchJSONTLS

func HTTPPatchJSONTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchJSONTLS patch tls 请求

content-type=application/json

func HTTPPatchJSONTLSBytes

func HTTPPatchJSONTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchJSONTLSBytes patch tls 请求

content-type=application/json

func HTTPPatchMsgPack

func HTTPPatchMsgPack(url string, model interface{}) (resp *http.Response, err error)

HTTPPatchMsgPack patch 请求

content-type=application/x-msgpack

func HTTPPatchMsgPackTLS

func HTTPPatchMsgPackTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchMsgPackTLS patch tls 请求

content-type=application/x-msgpack

func HTTPPatchMsgPackTLSBytes

func HTTPPatchMsgPackTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchMsgPackTLSBytes patch tls 请求

content-type=application/x-msgpack

func HTTPPatchProtoBuf

func HTTPPatchProtoBuf(url string, pm proto.Message) (resp *http.Response, err error)

HTTPPatchProtoBuf patch 请求

content-type=application/x-protobuf

func HTTPPatchProtoBufTLS

func HTTPPatchProtoBufTLS(url string, pm proto.Message, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchProtoBufTLS patch tls 请求

content-type=application/x-protobuf

func HTTPPatchProtoBufTLSBytes

func HTTPPatchProtoBufTLSBytes(url string, pm proto.Message, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchProtoBufTLSBytes patch tls 请求

content-type=application/x-protobuf

func HTTPPatchXML

func HTTPPatchXML(url string, model interface{}) (resp *http.Response, err error)

HTTPPatchXML patch 请求

content-type=application/xml

func HTTPPatchXMLTLS

func HTTPPatchXMLTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchXMLTLS patch tls 请求

content-type=application/xml

func HTTPPatchXMLTLSBytes

func HTTPPatchXMLTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchXMLTLSBytes patch tls 请求

content-type=application/xml

func HTTPPatchYaml

func HTTPPatchYaml(url string, model interface{}) (resp *http.Response, err error)

HTTPPatchYaml patch 请求

content-type=application/x-yaml

func HTTPPatchYamlTLS

func HTTPPatchYamlTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPatchYamlTLS patch tls 请求

content-type=application/x-yaml

func HTTPPatchYamlTLSBytes

func HTTPPatchYamlTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPatchYamlTLSBytes patch tls 请求

content-type=application/x-yaml

func HTTPPostForm

func HTTPPostForm(url string, paramMap map[string]string) (resp *http.Response, err error)

HTTPPostForm post 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostFormMultipart

func HTTPPostFormMultipart(url string, paramMap map[string]string, fileMap map[string]string) (resp *http.Response, err error)

HTTPPostFormMultipart post 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostFormMultipartTLS

func HTTPPostFormMultipartTLS(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostFormMultipartTLS post tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostFormMultipartTLSBytes

func HTTPPostFormMultipartTLSBytes(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostFormMultipartTLSBytes post tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostFormTLS

func HTTPPostFormTLS(url string, paramMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostFormTLS post tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostFormTLSBytes

func HTTPPostFormTLSBytes(url string, paramMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostFormTLSBytes post tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPostJSON

func HTTPPostJSON(url string, model interface{}) (resp *http.Response, err error)

HTTPPostJSON post 请求

content-type=application/json

func HTTPPostJSONTLS

func HTTPPostJSONTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostJSONTLS post tls 请求

content-type=application/json

func HTTPPostJSONTLSBytes

func HTTPPostJSONTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostJSONTLSBytes post tls 请求

content-type=application/json

func HTTPPostMsgPack

func HTTPPostMsgPack(url string, model interface{}) (resp *http.Response, err error)

HTTPPostMsgPack post 请求

content-type=application/x-msgpack

func HTTPPostMsgPackTLS

func HTTPPostMsgPackTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostMsgPackTLS post tls 请求

content-type=application/x-msgpack

func HTTPPostMsgPackTLSBytes

func HTTPPostMsgPackTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostMsgPackTLSBytes post tls 请求

content-type=application/x-msgpack

func HTTPPostProtoBuf

func HTTPPostProtoBuf(url string, pm proto.Message) (resp *http.Response, err error)

HTTPPostProtoBuf post 请求

content-type=application/x-protobuf

func HTTPPostProtoBufTLS

func HTTPPostProtoBufTLS(url string, pm proto.Message, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostProtoBufTLS post tls 请求

content-type=application/x-protobuf

func HTTPPostProtoBufTLSBytes

func HTTPPostProtoBufTLSBytes(url string, pm proto.Message, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostProtoBufTLSBytes post tls 请求

content-type=application/x-protobuf

func HTTPPostXML

func HTTPPostXML(url string, model interface{}) (resp *http.Response, err error)

HTTPPostXML post 请求

content-type=application/xml

func HTTPPostXMLTLS

func HTTPPostXMLTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostXMLTLS post tls 请求

content-type=application/xml

func HTTPPostXMLTLSBytes

func HTTPPostXMLTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostXMLTLSBytes post tls 请求

content-type=application/xml

func HTTPPostYaml

func HTTPPostYaml(url string, model interface{}) (resp *http.Response, err error)

HTTPPostYaml post 请求

content-type=application/x-yaml

func HTTPPostYamlTLS

func HTTPPostYamlTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPostYamlTLS post tls 请求

content-type=application/x-yaml

func HTTPPostYamlTLSBytes

func HTTPPostYamlTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPostYamlTLSBytes post tls 请求

content-type=application/x-yaml

func HTTPPutForm

func HTTPPutForm(url string, paramMap map[string]string) (resp *http.Response, err error)

HTTPPutForm put 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutFormMultipart

func HTTPPutFormMultipart(url string, paramMap map[string]string, fileMap map[string]string) (resp *http.Response, err error)

HTTPPutFormMultipart put 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutFormMultipartTLS

func HTTPPutFormMultipartTLS(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutFormMultipartTLS put tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutFormMultipartTLSBytes

func HTTPPutFormMultipartTLSBytes(url string, paramMap map[string]string, fileMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutFormMultipartTLSBytes put tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutFormTLS

func HTTPPutFormTLS(url string, paramMap map[string]string, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutFormTLS put tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutFormTLSBytes

func HTTPPutFormTLSBytes(url string, paramMap map[string]string, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutFormTLSBytes put tls 请求

paramMap form普通参数

fileMap form附件key及附件路径

func HTTPPutJSON

func HTTPPutJSON(url string, model interface{}) (resp *http.Response, err error)

HTTPPutJSON put 请求

content-type=application/json

func HTTPPutJSONTLS

func HTTPPutJSONTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutJSONTLS put tls 请求

content-type=application/json

func HTTPPutJSONTLSBytes

func HTTPPutJSONTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutJSONTLSBytes put tls 请求

content-type=application/json

func HTTPPutMsgPack

func HTTPPutMsgPack(url string, model interface{}) (resp *http.Response, err error)

HTTPPutMsgPack put 请求

content-type=application/x-msgpack

func HTTPPutMsgPackTLS

func HTTPPutMsgPackTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutMsgPackTLS put tls 请求

content-type=application/x-msgpack

func HTTPPutMsgPackTLSBytes

func HTTPPutMsgPackTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutMsgPackTLSBytes put tls 请求

content-type=application/x-msgpack

func HTTPPutProtoBuf

func HTTPPutProtoBuf(url string, pm proto.Message) (resp *http.Response, err error)

HTTPPutProtoBuf put 请求

content-type=application/x-protobuf

func HTTPPutProtoBufTLS

func HTTPPutProtoBufTLS(url string, pm proto.Message, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutProtoBufTLS put tls 请求

content-type=application/x-protobuf

func HTTPPutProtoBufTLSBytes

func HTTPPutProtoBufTLSBytes(url string, pm proto.Message, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutProtoBufTLSBytes put tls 请求

content-type=application/x-protobuf

func HTTPPutXML

func HTTPPutXML(url string, model interface{}) (resp *http.Response, err error)

HTTPPutXML put 请求

content-type=application/xml

func HTTPPutXMLTLS

func HTTPPutXMLTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutXMLTLS put tls 请求

content-type=application/xml

func HTTPPutXMLTLSBytes

func HTTPPutXMLTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutXMLTLSBytes put tls 请求

content-type=application/xml

func HTTPPutYaml

func HTTPPutYaml(url string, model interface{}) (resp *http.Response, err error)

HTTPPutYaml put 请求

content-type=application/x-yaml

func HTTPPutYamlTLS

func HTTPPutYamlTLS(url string, model interface{}, tlsConfig *HTTPTLSConfig) (resp *http.Response, err error)

HTTPPutYamlTLS put tls 请求

content-type=application/x-yaml

func HTTPPutYamlTLSBytes

func HTTPPutYamlTLSBytes(url string, model interface{}, tlsConfig *HTTPTLSBytesConfig) (resp *http.Response, err error)

HTTPPutYamlTLSBytes put tls 请求

content-type=application/x-yaml

func HashMD5

func HashMD5(text string) string

HashMD5 MD5

func HashMD516

func HashMD516(text string) string

HashMD516 MD516

func HashMD516Bytes

func HashMD516Bytes(bytes []byte) string

HashMD516Bytes MD516Bytes

func HashMD5Bytes

func HashMD5Bytes(bytes []byte) string

HashMD5Bytes MD5Bytes

func HashSha1

func HashSha1(text string) string

HashSha1 Sha1

func HashSha1Bytes

func HashSha1Bytes(bytes []byte) string

HashSha1Bytes Sha1Bytes

func HashSha224

func HashSha224(text string) string

HashSha224 Sha224

func HashSha224Bytes

func HashSha224Bytes(bytes []byte) string

HashSha224Bytes Sha224Bytes

func HashSha256

func HashSha256(text string) string

HashSha256 Sha256

func HashSha256Bytes

func HashSha256Bytes(bytes []byte) string

HashSha256Bytes Sha256Bytes

func HashSha384

func HashSha384(text string) string

HashSha384 Sha384

func HashSha384Bytes

func HashSha384Bytes(bytes []byte) string

HashSha384Bytes Sha384Bytes

func HashSha512

func HashSha512(text string) string

HashSha512 Sha512

func HashSha512Bytes

func HashSha512Bytes(bytes []byte) string

HashSha512Bytes Sha512Bytes

func IPGet

func IPGet(req *http.Request) string

IPGet 返回客户端 IP

func IntToBytes

func IntToBytes(n int) ([]byte, error)

IntToBytes int转换成字节

func JWTBuild

func JWTBuild(method int, key interface{}, sub, iss, jti string, iat, nbf, exp int64) (string, error)

JWTBuild 创建一个 jwt token

"sub": "1", 该JWT所面向的用户

"iss": "http://localhost:8000/user/sign_up", 该JWT的签发者

"iat": 1451888119, 在什么时候签发的token

"exp": 1454516119, token什么时候过期

"nbf": 1451888119, token在此时间之前不能被接收处理

"jti": "37c107e4609ddbcc9c096ea5ee76c667" token提供唯一标识

func JWTCheck

func JWTCheck(key interface{}, token string) bool

JWTCheck 验证传入 token 是否合法

func NewSpinLock

func NewSpinLock() sync.Locker

NewSpinLock 新建自旋锁

func RSADecrypt

func RSADecrypt(privateKey, data []byte, pemType string, pks PKSCType) ([]byte, error)

RSADecrypt 私钥解密

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

data 待解密数据

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSADecryptFP

func RSADecryptFP(privateKeyFilePath, pemType string, data []byte, pks PKSCType) ([]byte, error)

RSADecryptFP 私钥解密

privateKeyFilePath 私钥地址

data 待解密数据

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSADecryptFPWithPass

func RSADecryptFPWithPass(privateKeyFilePath, passwd, pemType string, data []byte, pks PKSCType) ([]byte, error)

RSADecryptFPWithPass 私钥解密

privateKeyFilePath 私钥地址

passwd 生成privateKey时输入密码

data 待解密数据

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSADecryptWithPass

func RSADecryptWithPass(privateKey, data []byte, passwd, pemType string, pks PKSCType) ([]byte, error)

RSADecryptWithPass 私钥解密

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

data 待解密数据

passwd 生成privateKey时输入密码

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAEncrypt

func RSAEncrypt(publicKey, data []byte, pemType string) ([]byte, error)

RSAEncrypt 公钥加密

publicKey 公钥内容,如取出字符串'pubData',则传入'string(pubData)'即可

data 待加密数据

func RSAEncryptFP

func RSAEncryptFP(publicKeyFilePath, pemType string, data []byte) ([]byte, error)

RSAEncryptFP 公钥加密

publicKeyFilePath 公钥地址

data 待加密数据

func RSAGenerateKey

func RSAGenerateKey(bits int, path, priFileName, pubFileName, priPemType, pubPemType string, pks PKSCType) error

RSAGenerateKey RSA公钥私钥产生

bits 指定生成位大小

path 指定公私钥所在生成目录

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGenerateKeyPemBytes

func RSAGenerateKeyPemBytes(bits int, priPemType, pubPemType, passwd string, pks PKSCType) (priBytes, pubBytes []byte, err error)

RSAGenerateKeyPemBytes RSA公钥私钥产生

bits 指定生成位大小

path 指定公私钥所在生成目录

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGenerateKeyWithPass

func RSAGenerateKeyWithPass(bits int, path, priFileName, pubFileName, passwd, priPemType, pubPemType string, alg x509.PEMCipher, pks PKSCType) error

RSAGenerateKeyWithPass RSA公钥私钥产生

bits 指定生成位大小

path 指定公私钥所在生成目录

passwd 生成密码

alg der编码数据指定算法,如:x509.PEMCipher3DES

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePriKey

func RSAGeneratePriKey(bits int, path, fileName, pemType string, pks PKSCType) (*rsa.PrivateKey, error)

RSAGeneratePriKey RSA私钥产生

bits 指定生成位大小

path 指定私钥所在生成目录

fileName 指定私钥的文件名称,如'private.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePriKeyWithPass

func RSAGeneratePriKeyWithPass(bits int, path, fileName, passwd, pemType string, alg x509.PEMCipher, pks PKSCType) (*rsa.PrivateKey, error)

RSAGeneratePriKeyWithPass RSA私钥产生

bits 指定生成位大小

path 指定私钥所在生成目录

fileName 指定私钥的文件名称,如'private.pem'

passwd 生成密码

alg der编码数据指定算法,如:x509.PEMCipher3DES

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePubKey

func RSAGeneratePubKey(privateKey *rsa.PrivateKey, path, fileName, pemType string) error

RSAGeneratePubKey RSA公钥产生

privateKey 私钥

path 指定公私钥所在生成目录

fileName 指定公钥的文件名称,如'public.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePubKeyBytes

func RSAGeneratePubKeyBytes(privateKey []byte, path, fileName, priPemType, pubPemType string, pks PKSCType) error

RSAGeneratePubKeyBytes RSA公钥产生

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

path 指定公私钥所在生成目录

fileName 指定公钥的文件名称,如'public.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePubKeyBytesWithPass

func RSAGeneratePubKeyBytesWithPass(privateKey []byte, passwd, path, fileName, priPemType, pubPemType string, pks PKSCType) error

RSAGeneratePubKeyBytesWithPass RSA公钥产生

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

passwd 生成privateKey时输入密码

path 指定公私钥所在生成目录

fileName 指定公钥的文件名称,如'public.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePubKeyFP

func RSAGeneratePubKeyFP(privateKeyFilePath, path, fileName, priPemType, pubPemType string, pks PKSCType) error

RSAGeneratePubKeyFP RSA公钥产生

privateKeyFilePath 私钥地址

path 指定公私钥所在生成目录

fileName 指定公钥的文件名称,如'public.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAGeneratePubKeyFPWithPass

func RSAGeneratePubKeyFPWithPass(privateKeyFilePath, passwd, path, fileName, priPemType, pubPemType string, pks PKSCType) error

RSAGeneratePubKeyFPWithPass RSA公钥产生

privateKeyFilePath 私钥地址

passwd 生成privateKey时输入密码

path 指定公私钥所在生成目录

fileName 指定公钥的文件名称,如'public.pem'

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSALoadPri

func RSALoadPri(privateKey []byte, pemType string, pks PKSCType) (*rsa.PrivateKey, error)

RSALoadPri 解析私钥

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSALoadPriFP

func RSALoadPriFP(privateKeyFilePath, pemType string, pks PKSCType) (*rsa.PrivateKey, error)

RSALoadPriFP 加载私钥

privateKeyFilePath 私钥地址

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSALoadPriFPWithPass

func RSALoadPriFPWithPass(privateKeyFilePath, passwd, pemType string, pks PKSCType) (*rsa.PrivateKey, error)

RSALoadPriFPWithPass 加载私钥

privateKeyFilePath 私钥地址

passwd 生成privateKey时输入密码

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSALoadPriWithPass

func RSALoadPriWithPass(privateKey []byte, passwd, pemType string, pks PKSCType) (*rsa.PrivateKey, error)

RSALoadPriWithPass 解析私钥

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

passwd 生成privateKey时输入密码

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSALoadPub

func RSALoadPub(publicKey []byte, pemType string) (*rsa.PublicKey, error)

RSALoadPub 加载公钥

publicKey 公钥内容,如取出字符串'pubData',则传入'string(pubData)'即可

func RSALoadPubFP

func RSALoadPubFP(publicKeyFilePath, pemType string) (*rsa.PublicKey, error)

RSALoadPubFP 加载公钥

publicKeyFilePath 公钥地址

func RSAPri2PemBytes

func RSAPri2PemBytes(priPemType, passwd string, privateKey *rsa.PrivateKey, pks PKSCType) (data []byte, err error)

RSAPri2PemBytes RSAPri2PemBytes

func RSAPub2PemBytes

func RSAPub2PemBytes(pubPemType string, publicKey *rsa.PublicKey) (data []byte, err error)

RSAPub2PemBytes RSAPub2PemBytes

func RSASavePriPem

func RSASavePriPem(privateKey *rsa.PrivateKey, path, fileName, pemType string, alg x509.PEMCipher, pks PKSCType) error

RSASavePriPem 将私钥保存到给定文件

alg der编码数据指定算法,如:x509.PEMCipher3DES

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSASavePriPemWithPass

func RSASavePriPemWithPass(privateKey *rsa.PrivateKey, path, fileName, passwd, pemType string, alg x509.PEMCipher, pks PKSCType) error

RSASavePriPemWithPass 将私钥保存到给定文件

alg der编码数据指定算法,如:x509.PEMCipher3DES

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSASign

func RSASign(privateKey, data []byte, pemType string, hash crypto.Hash, pks PKSCType, mod SignMode) ([]byte, error)

RSASign 签名:采用RSA-PKCS#1 v1.5模式

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

data 待签名数据

hash 算法,如 crypto.SHA1/crypto.SHA256等

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSASignFP

func RSASignFP(privateKeyPath, pemType string, data []byte, hash crypto.Hash, pks PKSCType, mod SignMode) ([]byte, error)

RSASignFP 签名:采用RSA-PKCS#1 v1.5模式

privateKeyPath 私钥文件存储路径

data 待签名数据

hash 算法,如 crypto.SHA1/crypto.SHA256等

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSASignFPWithPass

func RSASignFPWithPass(privateKeyPath, passwd, pemType string, data []byte, hash crypto.Hash, pks PKSCType, mod SignMode) ([]byte, error)

RSASignFPWithPass 签名:采用RSA-PKCS#1 v1.5模式

privateKeyPath 私钥文件存储路径

passwd 生成privateKey时输入密码

data 待签名数据

hash 算法,如 crypto.SHA1/crypto.SHA256等

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSASignWithPass

func RSASignWithPass(privateKey, data []byte, passwd, pemType string, hash crypto.Hash, pks PKSCType, mod SignMode) ([]byte, error)

RSASignWithPass 签名:采用RSA-PKCS#1 v1.5模式

privateKey 私钥内容,如取出字符串'priData',则传入'string(priData)'即可

data 待签名数据

passwd 生成privateKey时输入密码

hash 算法,如 crypto.SHA1/crypto.SHA256等

pks 私钥格式,默认提供PKCS1和PKCS8,通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSAVerify

func RSAVerify(publicKey, data, signData []byte, pemType string, hash crypto.Hash, mod SignMode) error

RSAVerify 验签:采用RSA-PKCS#1 v1.5模式

publicKey 公钥内容,如取出字符串'pubData',则传入'string(pubData)'即可

data 待签名数据

hash 算法,如 crypto.SHA1/crypto.SHA256等

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSAVerifyFP

func RSAVerifyFP(publicKeyPath, pemType string, data, signData []byte, hash crypto.Hash, mod SignMode) error

RSAVerifyFP 验签:采用RSA-PKCS#1 v1.5模式

publicKeyPath 公钥文件存储路径

data 待签名数据

hash 算法,如 crypto.SHA1/crypto.SHA256等

mod RSA签名模式,默认提供PSS和PKCS1v15,通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func SM2Generate

func SM2Generate() (pri *sm2.PrivateKey, pub *sm2.PublicKey, err error)

SM2Generate SM2公钥私钥产生

path 指定公私钥所在生成目录

func SM2GeneratePemBytes

func SM2GeneratePemBytes(priPemType, pubPemType, passwd string) (priBytes, pubBytes []byte, err error)

SM2GeneratePemBytes SM2公钥私钥产生

func SM2Pri2PemBytes

func SM2Pri2PemBytes(priPemType, passwd string, pri *sm2.PrivateKey) (data []byte, err error)

SM2Pri2PemBytes SM2Pri2Bytes

func SM2Pub2PemBytes

func SM2Pub2PemBytes(pubPemType string, pub *sm2.PublicKey) (data []byte, err error)

SM2Pub2PemBytes SM2Pub2PemBytes

func ScaleDDuoStringToInt64

func ScaleDDuoStringToInt64(dDuo string) int64

ScaleDDuoStringToInt64 int字符串转int

func ScaleDDuoStringToUint64

func ScaleDDuoStringToUint64(dDuo string) uint64

ScaleDDuoStringToUint64 int字符串转int

func ScaleDuoStringToInt64

func ScaleDuoStringToInt64(duo string) int64

ScaleDuoStringToInt64 int字符串转int

func ScaleDuoStringToUint64

func ScaleDuoStringToUint64(duo string) uint64

ScaleDuoStringToUint64 int字符串转int

func ScaleFloat64toInt64

func ScaleFloat64toInt64(num float64, retain int) int64

ScaleFloat64toInt64 将float64转成精确的int64

func ScaleHexStringToInt64

func ScaleHexStringToInt64(hex string) int64

ScaleHexStringToInt64 int字符串转int

func ScaleHexStringToUint64

func ScaleHexStringToUint64(hex string) uint64

ScaleHexStringToUint64 int字符串转int

func ScaleInt32Len

func ScaleInt32Len(i int32) int

ScaleInt32Len 计算整型字符串长度

func ScaleInt32ToDDuoString

func ScaleInt32ToDDuoString(i int32) string

ScaleInt32ToDDuoString int32转十六进制字符串

func ScaleInt32ToDuoString

func ScaleInt32ToDuoString(i int32) string

ScaleInt32ToDuoString int32转十六进制字符串

func ScaleInt32ToHexString

func ScaleInt32ToHexString(i int32) string

ScaleInt32ToHexString int32转十六进制字符串

func ScaleInt64Len

func ScaleInt64Len(i int64) int

ScaleInt64Len 计算整型字符串长度

func ScaleInt64ToDDuoString

func ScaleInt64ToDDuoString(i int64) string

ScaleInt64ToDDuoString int64转十六进制字符串

func ScaleInt64ToDuoString

func ScaleInt64ToDuoString(i int64) string

ScaleInt64ToDuoString int64转十六进制字符串

func ScaleInt64ToHexString

func ScaleInt64ToHexString(i int64) string

ScaleInt64ToHexString int64转十六进制字符串

func ScaleInt64toFloat64

func ScaleInt64toFloat64(num int64, retain int) float64

ScaleInt64toFloat64 将int64恢复成正常的float64

func ScaleIntLen

func ScaleIntLen(i int) int

ScaleIntLen 计算整型字符串长度

func ScaleIntToDDuoString

func ScaleIntToDDuoString(i int) string

ScaleIntToDDuoString int转64进制字符串

func ScaleIntToDuoString

func ScaleIntToDuoString(i int) string

ScaleIntToDuoString int转十六进制字符串

func ScaleIntToHexString

func ScaleIntToHexString(i int) string

ScaleIntToHexString int转十六进制字符串

func ScaleUint32Len

func ScaleUint32Len(i uint32) int

ScaleUint32Len 计算整型字符串长度

func ScaleUint32ToDDuoString

func ScaleUint32ToDDuoString(i uint32) string

ScaleUint32ToDDuoString uint32转十六进制字符串

func ScaleUint32ToDuoString

func ScaleUint32ToDuoString(i uint32) string

ScaleUint32ToDuoString uint32转十六进制字符串

func ScaleUint32ToHexString

func ScaleUint32ToHexString(i uint32) string

ScaleUint32ToHexString uint32转十六进制字符串

func ScaleUint32toFullState

func ScaleUint32toFullState(index uint32) string

ScaleUint32toFullState 补全不满十位数状态,如1->0000000001、34->0000000034、215->0000000215

func ScaleUint64Len

func ScaleUint64Len(i uint64) int

ScaleUint64Len 计算整型字符串长度

func ScaleUint64ToDDuoString

func ScaleUint64ToDDuoString(i uint64) string

ScaleUint64ToDDuoString uint64转十六进制字符串

func ScaleUint64ToDuoString

func ScaleUint64ToDuoString(i uint64) string

ScaleUint64ToDuoString uint64转十六进制字符串

func ScaleUint64ToHexString

func ScaleUint64ToHexString(i uint64) string

ScaleUint64ToHexString uint64转十六进制字符串

func ScaleUint8toFullState

func ScaleUint8toFullState(index uint8) string

ScaleUint8toFullState 补全不满三位数状态,如1->001、34->034、215->215

func ScaleUintLen

func ScaleUintLen(i uint) int

ScaleUintLen 计算整型字符串长度

func ScaleUintToDDuoString

func ScaleUintToDDuoString(i uint) string

ScaleUintToDDuoString int转64进制字符串

func ScaleUintToDuoString

func ScaleUintToDuoString(i uint) string

ScaleUintToDuoString uint转十六进制字符串

func ScaleUintToHexString

func ScaleUintToHexString(i uint) string

ScaleUintToHexString uint转十六进制字符串

func String2Timestamp

func String2Timestamp(date, format string, zone *time.Location) (int64, error)

String2Timestamp 字符串转时间戳

date 待转换时间字符串 如:2019/09/17 10:16:56

format 时间字符串格式化类型 如:2006/01/02 15:04:05

zone 时区 如:time.Local / time.UTC

func StringBuild

func StringBuild(arrString ...string) string

StringBuild 拼接字符串

func StringBuildSep

func StringBuildSep(sep string, arrString ...string) string

StringBuildSep 拼接字符串

func StringConvert

func StringConvert(oriString string) string

StringConvert 下划线转换,首字母小写变大写, 下划线去掉并将下划线后的首字母大写

func StringIsEmpty

func StringIsEmpty(str string) bool

StringIsEmpty 判断字符串是否为空,是则返回true,否则返回false

func StringIsNotEmpty

func StringIsNotEmpty(str string) bool

StringIsNotEmpty 和 IsEmpty 的语义相反

func StringPrefixSupplementZero

func StringPrefixSupplementZero(str string, offset int) string

StringPrefixSupplementZero 当字符串长度不满足时,将字符串前几位补充0

str 字符串内容

offset 字符串期望的长度

func StringRandSeq

func StringRandSeq(n int) string

StringRandSeq 创建指定长度的随机字符串

func StringRandSeq16

func StringRandSeq16() string

StringRandSeq16 创建长度为16的随机字符串

func StringSingleSpace

func StringSingleSpace(res string) string

StringSingleSpace 将字符串内所有连续空格替换为单个空格

func StringSingleValue

func StringSingleValue(res string, value string) string

StringSingleValue 将字符串内所有连续value替换为单个value

func StringTrim

func StringTrim(str string) string

StringTrim 去除字符串中的空格和换行符

func StringTrimN

func StringTrimN(str string) string

StringTrimN 去除字符串中的换行符

func SubString

func SubString(res string, start, end int) string

SubString 截取字符串

func Timestamp2String

func Timestamp2String(timestampSec, timestampNSec int64, format string, zone *time.Location) string

Timestamp2String 时间戳转字符串

timestampSec 时间戳秒值

timestampNSec 时间戳纳秒值

format 时间字符串格式化类型 如:2006/01/02 15:04:05

func ToString

func ToString(i interface{}) string

ToString 将对象格式化成字符串

func Uint16ToBytes

func Uint16ToBytes(i uint16) []byte

Uint16ToBytes uint16转换成字节

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

Uint32ToBytes uint32转换成字节

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Uint64ToBytes uint64转换成字节

Types

type Business

type Business func(conn *grpc.ClientConn) (interface{}, error)

Business 真实业务逻辑

type Cert

type Cert struct {
	ParentCert *x509.Certificate // 父证书对象
	CertSelf
}

Cert 签名数字证书对象

type CertRequest

type CertRequest struct {
	PrivateKeyData             []byte                  // privateKeyData 私钥字节数组
	CertificateRequestFilePath string                  // certificateFilePath 指定生成的证书签名请求文件路径,如'/etc/rootCA.csr'
	SignatureAlgorithm         x509.SignatureAlgorithm // signatureAlgorithm 生成证书时候采用的签名算法
	Subject                    pkix.Name               // Subject 签名信息
	DNSNames                   []string                // DNSNames DNS限制
	EmailAddresses             []string                // EmailAddresses 邮箱地址限制
	IPAddresses                []net.IP                // IPAddresses IP地址限制
	URIs                       []*url.URL              // URIs URL地址限制
}

CertRequest 证书生成请求对象

type CertRequestFP

type CertRequestFP struct {
	PrivateKeyFilePath         string                  // privateKeyFilePath 私钥文件存储路径
	CertificateRequestFilePath string                  // certificateFilePath 指定生成的证书签名请求文件路径,如'/etc/rootCA.csr'
	SignatureAlgorithm         x509.SignatureAlgorithm // signatureAlgorithm 生成证书时候采用的签名算法
	Subject                    pkix.Name               // Subject 签名信息
	DNSNames                   []string                // DNSNames DNS限制
	EmailAddresses             []string                // EmailAddresses 邮箱地址限制
	IPAddresses                []net.IP                // IPAddresses IP地址限制
	URIs                       []*url.URL              // URIs URL地址限制
}

CertRequestFP 证书生成请求对象

type CertRequestModel

type CertRequestModel struct {
	PrivateKey                 crypto.Signer            // privateKey 私钥字节数组
	CertificateRequestFilePath string                   // certificateFilePath 指定生成的证书签名请求文件路径,如'/etc/rootCA.csr'
	Template                   *x509.CertificateRequest // template 生成证书时候采用的请求模板
}

CertRequestModel 证书生成请求对象

type CertSelf

type CertSelf struct {
	CertificateFilePath         string                  // 签名后数字证书文件存储路径
	Subject                     pkix.Name               // Subject 签名信息
	ParentPrivateKey, PublicKey interface{}             // 公私钥
	BasicConstraintsValid       bool                    // 基本的有效性约束
	IsCA                        bool                    // 是否是根证书
	NotBeforeDays, NotAfterDays time.Time               // 在指定时间之后生效及之前失效
	ExtKeyUsage                 []x509.ExtKeyUsage      // ExtKeyUsage表示对给定键有效的扩展操作集。每个ExtKeyUsage*常量定义一个惟一的操作。
	KeyUsage                    x509.KeyUsage           // KeyUsage表示对给定密钥有效的操作集。它是KeyUsage*常量的位图。
	SignatureAlgorithm          x509.SignatureAlgorithm // signatureAlgorithm 生成证书时候采用的签名算法
	DNSNames                    []string                // DNSNames DNS限制
	EmailAddresses              []string                // EmailAddresses 邮箱地址限制
	IPAddresses                 []net.IP                // IPAddresses IP地址限制
	URIs                        []*url.URL              // URIs URL地址限制
}

CertSelf 自签名数字证书对象

type CommandAsync

type CommandAsync struct {
	Command *exec.Cmd
	Tail    string
	Err     error
}

CommandAsync 异步命令执行归属通道对象

type Conn

type Conn interface {
	io.Closer // 实现io.Closer接口的对象都可以使用该连接池
}

Conn 连接单体接口

type Field

type Field struct {
	Name   string        // 参数名
	Value  reflect.Value // 参数值
	Tag    string        // 参数标签
	Kind   reflect.Kind  // 参数类型
	Fields []*Field      // 自身作为根结构体信息
}

Field 上一结构体所属参数信息

type HTTPTLSBytesConfig

type HTTPTLSBytesConfig struct {
	RootCrtBytes       []byte // 服务端根证书,用于我方验证对方证书合法性
	CertBytes          []byte // 服务端签发的子证书,用于对方验证我方证书合法性
	KeyBytes           []byte // 客户端私钥,用于对方验证我方证书合法性
	InsecureSkipVerify bool   // 是否验证服务端证书,即双向认证
}

HTTPTLSBytesConfig http tls 请求配置

type HTTPTLSConfig

type HTTPTLSConfig struct {
	RootCrtFilePath    string // 服务端根证书,用于我方验证对方证书合法性
	CertFilePath       string // 服务端签发的子证书,用于对方验证我方证书合法性
	KeyFilePath        string // 客户端私钥,用于对方验证我方证书合法性
	InsecureSkipVerify bool   // 是否验证服务端证书,即双向认证
}

HTTPTLSConfig http tls 请求配置

type PKSCType

type PKSCType string

PKSCType 私钥格式,默认提供PKCS1和PKCS8

通过调用‘CryptoRSA().PKSC1()’和‘CryptoRSA().PKSC8()’方法赋值

func RSAPKSC1

func RSAPKSC1() PKSCType

RSAPKSC1 私钥格PKCS1

func RSAPKSC8

func RSAPKSC8() PKSCType

RSAPKSC8 私钥格式PKCS8

type Pond

type Pond struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Pond 连接池对象

func NewPond

func NewPond(minOpen, maxOpen int, factory factory) *Pond

NewPond 新建一个支持所有实现 io.Closer 接口的连接池

minOpen 池中最少资源数

maxOpen 池中最大资源数

factory

func (*Pond) Acquire

func (p *Pond) Acquire() (Conn, error)

Acquire 获取资源

func (*Pond) Close

func (p *Pond) Close(conn Conn)

Close 关闭单个资源

func (*Pond) Release

func (p *Pond) Release(conn Conn) error

Release 释放单个资源到连接池

func (*Pond) Shutdown

func (p *Pond) Shutdown() error

Shutdown 关闭连接池,释放所有资源

type Schema

type Schema struct {
	Model  interface{}
	Name   string // 结构体名称
	Fields []*Field
	// contains filtered or unexported fields
}

Schema 根结构体信息

func SchemaParse

func SchemaParse(key string, dest interface{}) *Schema

SchemaParse SchemaParse

func (*Schema) GetField

func (schema *Schema) GetField(name string) *Field

GetField GetField

func (*Schema) GetValue

func (schema *Schema) GetValue(name string) reflect.Value

GetValue GetValue

type SignMode

type SignMode string

SignMode RSA签名模式,默认提供PSS和PKCS1v15

通过调用‘CryptoRSA().SignPSS()’和‘CryptoRSA().SignPKCS()’方法赋值

func RSASignPKCS

func RSASignPKCS() SignMode

RSASignPKCS RSA签名模式,PKCS1v15

func RSASignPSS

func RSASignPSS() SignMode

RSASignPSS RSA签名模式,PSS

Directories

Path Synopsis
example
sql

Jump to

Keyboard shortcuts

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