gone

package module
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 47 Imported by: 5

README

gone

gone is a simple, convenient, small and easy-to-use tool kit

GoDoc Build Status

Feature

  • RSA
  • SM2
  • Random
  • FileUtils
  • StrUtils and StrConv
  • AES Block Encrypt
  • Datetime Format
  • ID generator
  • HASH
  • Base64
  • Log
  • Script
  • File Uploader & File Receive
  • Retry
  • Other

Documentation

Index

Constants

View Source
const (
	KiB // 1 KiB = 1024 Bytes
	MiB // 1 MiB = 1048576 Bytes
	GiB // 1 GiB = 1073741824 Bytes
	TiB // 1 TiB = 1099511627776 Bytes
	PiB // 1 PiB = 1125899906842624 Bytes
	EiB // 1 EiB = 1152921504606846976 Bytes
)

binary units (IEC 60027)

View Source
const (
	KB = 1000
	MB = 1_000_000
	GB = 1_000_000_000
	TB = 1_000_000_000_000
	PB = 1_000_000_000_000_000
	EB = 1_000_000_000_000_000_000
)

Variables

View Source
var (

	// ErrECDSANilPubKey is the error for trying to verify a JWT with a nil public key.
	ErrECDSANilPubKey = errors.New("jwt: ECDSA public key is nil")
	// ErrECDSAVerification is the error for an invalid ECDSA signature.
	ErrECDSAVerification = errors.New("jwt: ECDSA verification failed")

	// ErrRSANilPubKey is the error for trying to verify a JWT with a nil public key.
	ErrRSANilPubKey = errors.New("jwt: RSA public key is nil")
	// ErrRSAVerification is the error for an invalid RSA signature.
	ErrRSAVerification = errors.New("jwt: RSA verification failed")

	// ErrHmacVerification is the error for an invalid RSA signature.
	ErrHmacVerification = errors.New("jwt: Hmac verification failed")
)
View Source
var Epoch = time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)

Epoch is 01/01/1970.

View Source
var ErrMalformed = errors.New("jwt: malformed token")

ErrMalformed indicates a token doesn't have a valid format, as per the RFC 7519.

View Source
var ErrNotJSONObject = errors.New("jwt: payload is not a valid JSON object")

ErrNotJSONObject is the error for when a JWT payload is not a JSON object.

View Source
var ID id

Functions

func AfterStopFunc added in v1.2.0

func AfterStopFunc(d time.Duration, f func(<-chan struct{}))

AfterStopFunc 超时停止协程,关闭协程。使用原始channel实现 这里新建了两个channel是防止关闭一个已经关闭的channel导致panic,这里还有优化点。 该函数主使用场景,比如防止扫描磁盘时间过长,在规定时间里获取结果.

func AfterStopWithContext added in v1.2.0

func AfterStopWithContext(d time.Duration, f func(context.Context))

AfterStopWithContext 超时停止协程,关闭协程。使用context实现.

func Base64RawStdDecode added in v1.3.6

func Base64RawStdDecode(value []byte) ([]byte, error)

Base64RawStdDecode base标准解码

func Base64RawStdEncode added in v1.3.6

func Base64RawStdEncode(value []byte) []byte

Base64RawStdEncode baseRaw标准编码

func Base64RawURLDecode added in v1.3.6

func Base64RawURLDecode(value []byte) ([]byte, error)

Base64RawURLDecode baseRawURL解码

func Base64RawURLEncode added in v1.3.6

func Base64RawURLEncode(value []byte) []byte

Base64RawURLEncode baseRawURL编码

func Base64StdDecode added in v1.3.4

func Base64StdDecode(value []byte) ([]byte, error)

Base64StdDecode base标准解码

func Base64StdEncode added in v1.3.4

func Base64StdEncode(value []byte) []byte

Base64StdEncode base标准编码

func Base64URLDecode added in v1.3.4

func Base64URLDecode(value []byte) ([]byte, error)

Base64URLDecode baseURL解码

func Base64URLEncode added in v1.3.4

func Base64URLEncode(value []byte) []byte

Base64URLEncode baseURL编码

func BlockDecrypt added in v1.3.5

func BlockDecrypt(block cipher.Block, mode BlockStreamMode, value []byte) ([]byte, error)

func BlockEncrypt added in v1.3.5

func BlockEncrypt(block cipher.Block, mode BlockStreamMode, value []byte) ([]byte, error)

func BytesToStr

func BytesToStr(b []byte) string

BytesToStr []byte转string.

func CONNECT added in v1.2.0

func CONNECT(pattern string, handlerFunc http.HandlerFunc)

func Contains

func Contains(str string, s []string) bool

Contains 判断字符串是否存在切片中.

func DELETE added in v1.2.0

func DELETE(pattern string, handlerFunc http.HandlerFunc)

func DecodePemHexBase64

func DecodePemHexBase64(data []byte) ([]byte, error)

DecodePemHexBase64 解析pem或者hex或者base64编码成der编码.

func DecryptByAesCBC added in v1.3.5

func DecryptByAesCBC(encrypted, key, iv []byte) (decrypted []byte, err error)

DecryptByAesCBC cbc模式解密.

func DecryptByAesCTR added in v1.3.5

func DecryptByAesCTR(origData, key []byte) (encrypted []byte, err error)

func DecryptByRSA added in v1.3.0

func DecryptByRSA(privateKey *rsa.PrivateKey, ciphertext []byte) ([]byte, error)

DecryptByRSA 使用RSA私钥解密.

func DecryptByRSABytes added in v1.3.0

func DecryptByRSABytes(privateKey []byte, ciphertext []byte) ([]byte, error)

DecryptByRSABytes 使用RSA私钥解密.

func DecryptBySM2 added in v1.3.6

func DecryptBySM2(privateKey *sm2.PrivateKey, ciphertext []byte) ([]byte, error)

DecryptBySM2 使用SM2私钥解密.

func DecryptBySM2Bytes added in v1.3.6

func DecryptBySM2Bytes(privateKey []byte, ciphertext []byte) (text []byte, err error)

func EncryptByAesCBC added in v1.3.5

func EncryptByAesCBC(origData, key, iv []byte) (encrypted []byte, err error)

EncryptByAesCBC 加密 AES-128 key长度:16, 24, 32 bytes 对应 AES-128, AES-192, AES-256. CBC比EBC更安全,但不可并行.

func EncryptByAesCTR added in v1.3.5

func EncryptByAesCTR(origData, key []byte) (encrypted []byte, err error)

func EncryptByRSA added in v1.3.0

func EncryptByRSA(publicKey *rsa.PublicKey, content []byte) ([]byte, error)

EncryptByRSA 使用RSA公钥加密.

func EncryptByRSABytes added in v1.3.0

func EncryptByRSABytes(publicKey, content []byte) ([]byte, error)

EncryptByRSABytes 使用RSA公钥加密.

func FileCopy

func FileCopy(source, dest string) (err error)

FileCopy 复制文件,代码仅供参考. Deprecated

func FileExist

func FileExist(file string) bool

FileExist 判断文件是否存在.

func FileFindPath

func FileFindPath(fname string) (string, error)

FileFindPath 获取文件名路径,首先判断文件是否可以直接访问,优先获取当前可执行文件夹下,再去找工作路径下.

func FileIsBinary

func FileIsBinary(content string) bool

FileIsBinary 判断文件是否是二进制文件.

func FileIsDir

func FileIsDir(path string) bool

FileIsDir 判断文件是否是目录.

func FileMove

func FileMove(src, dest string) error

FileMove 移动文件,代码仅供参考. Deprecated

func FileSize

func FileSize(path string) int64

FileSize 获取文件大小.

func FormatBinary added in v1.3.9

func FormatBinary(value int64) string

FormatBinary formats bytes integer to human readable string according to IEC 60027. For example, 31323 bytes will return 30.59KB.

func FormatBinaryDecimal added in v1.3.9

func FormatBinaryDecimal(value int64) string

FormatBinaryDecimal formats bytes integer to human readable string according to SI international system of units. For example, 31323 bytes will return 31.32KB.

func FormatByStr

func FormatByStr(tpl string, t int64) string

FormatByStr 将字符串中的时间变量(y年/m月/d日/h时/i分/s秒)转换成时间字符串.

func FormatBytesString added in v1.2.0

func FormatBytesString(b int64) string

FormatBytesString 格式化bytes单位成可阅读单位形式,由于电脑制造商使用的是1000为单位计算磁盘大小 所以基本上使用该函数格式化存储大小.

func FormatBytesStringOhMyGod added in v1.2.0

func FormatBytesStringOhMyGod(b int64) string

FormatBytesStringOhMyGod 格式化存储大小,理论上应该使用该方式格式化存储大小,但是实际上不是这样的,呜呜呜呜呜呜.

func GET added in v1.2.0

func GET(pattern string, handlerFunc http.HandlerFunc)

func GenerateBase64Key

func GenerateBase64Key(secretLength SecretKeyLengthType,
	secretFormat SecretKeyFormatType) (pkStr, pbkStr string, err error)

GenerateBase64Key 生成base64编码的公私钥.

func GenerateECDSAKey added in v1.3.4

func GenerateECDSAKey(privateWriter, publicWriter io.Writer, c elliptic.Curve) error

GenerateECDSAKey 生成PEM格式ECDSA公私钥,写入到io.Writer中.

func GenerateECDSAKeyToMemory added in v1.3.4

func GenerateECDSAKeyToMemory(c elliptic.Curve) (privateBytes []byte, publicBytes []byte, err error)

GenerateECDSAKeyToMemory 生成PEM格式ECDSA公私钥,返回字节格式.

func GenerateRSAKey added in v1.3.0

func GenerateRSAKey(privateWriter, publicWriter io.Writer, bits RSABit) error

GenerateRSAKey 生成PEM格式PKCS1的RSA公私钥,写入到io.Writer中.

func GenerateRSAKeyToMemory added in v1.3.0

func GenerateRSAKeyToMemory(bits RSABit) (privateBytes []byte, publicBytes []byte, err error)

GenerateRSAKeyToMemory 生成PEM格式PKCS1的RSA公私钥,返回字节格式.

func GenerateSSHKey added in v1.3.0

func GenerateSSHKey(bits RSABit) (pkBytes []byte, pbkBytes []byte, err error)

GenerateSSHKey 生成ssh密钥队.

func GetMonthRange

func GetMonthRange(year, month int) (beginTime, endTime int64, err error)

GetMonthRange 获得指定年份和月份的起始unix时间和截止unix时间.

func GetWeek

func GetWeek(t time.Time) int

GetWeek 获得星期的数字.

func HEAD(pattern string, handlerFunc http.HandlerFunc)

func HMacMD5 added in v1.3.5

func HMacMD5(data []byte, salt ...[]byte) string

HMacMD5 md5摘要算法,使用hmac算法生成hash,参数salt是多参数,实现多态的行为. 参考github.com/dxvgef/gommon/encrypt/sha.go中的hash算法.

func HMacSha256 added in v1.3.5

func HMacSha256(key []byte, value []byte) string

HMacSha256 生成hmac256摘要

func Handle added in v1.2.0

func Handle(pattern string, handlerFunc http.HandlerFunc)

func MD5 added in v1.2.0

func MD5(str []byte, salt ...[]byte) string

MD5 md5摘要算法,可以加盐,参数salt是多参数,实现多态的行为.

func MacAddr

func MacAddr() (upMac []string, err error)

MacAddr 获取机器mac地址,返回mac字串数组.

func NewHttpReceiveFile added in v1.3.10

func NewHttpReceiveFile(options ...ReceiveFileOption) func(r *http.Request) (HTTPReceiveFile, error)

NewHttpReceiveFile 创建http文件接收函数

func NewServeMux added in v1.2.0

func NewServeMux() *http.ServeMux

func OPTIONS added in v1.2.0

func OPTIONS(pattern string, handlerFunc http.HandlerFunc)

func PATCH added in v1.2.0

func PATCH(pattern string, handlerFunc http.HandlerFunc)

func POST added in v1.2.0

func POST(pattern string, handlerFunc http.HandlerFunc)

func PUT added in v1.2.0

func PUT(pattern string, handlerFunc http.HandlerFunc)

func ParseBinaryString added in v1.3.9

func ParseBinaryString(value string) (i int64, err error)

ParseBinaryString parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944.

func ParseBytes added in v1.3.9

func ParseBytes(value string) (int64, error)

ParseBytes parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944, and 6GB (6G is also valid) will return 6000000000.

func ParseRsaPrivateKey added in v1.3.4

func ParseRsaPrivateKey(derBytes []byte) (privateKey *rsa.PrivateKey, err error)

ParseRsaPrivateKey 解析私钥,derBytes可以使用DecodePemHexBase64函数获取.

func ParseRsaPublicKey added in v1.3.4

func ParseRsaPublicKey(derBytes []byte) (publicKey *rsa.PublicKey, err error)

ParseRsaPublicKey 解析公钥,derBytes可以使用DecodePemHexBase64函数获取.

func ParseRsaPublicKeyByJWK added in v1.3.8

func ParseRsaPublicKeyByJWK(jsonBytes []byte) (publicKey *rsa.PublicKey, err error)

func ParseSM2PublicKey added in v1.3.6

func ParseSM2PublicKey(derBytes []byte) (publicKey *sm2.PublicKey, err error)

ParseSM2PublicKey 解析公钥,derBytes可以使用DecodePemHexBase64函数获取.

func ParseStringDecimal added in v1.3.9

func ParseStringDecimal(value string) (i int64, err error)

ParseStringDecimal parses human readable bytes string to bytes integer. For example, 6GB (6G is also valid) will return 6000000000.

func RandAlphaString

func RandAlphaString(length int) string

RandAlphaString 生成随机长度字母. Deprecated

func RandBytes

func RandBytes(length int) []byte

RandBytes 生成随机长度字节.

func RandInt

func RandInt(min, max int) int

RandInt 指定范围内的随机数字.

func RandInt32

func RandInt32(min, max int32) int32

RandInt32 指定范围内的随机数字,max必须大于min.

func RandInt64

func RandInt64(min, max int64) int64

RandInt64 指定范围内的随机数字,max必须大于min.

func RandInts

func RandInts(from, to, size int) []int

RandInts 生成指定范围int类型数组.

func RandLower

func RandLower(l int) string

RandLower 指定长度的随机小写字母.

func RandString

func RandString(n int) string

RandString 生成随机长度字符串,推荐使用.

func RandUpper

func RandUpper(l int) string

RandUpper 指定长度的随机大写字母.

func Retry added in v1.2.0

func Retry(n uint, interval time.Duration, fn func() error) (err error)

Retry calls the `fn` and if it returns the error, retry to call `fn` after `interval` duration. The `fn` is called up to `n` times.

func Round added in v1.2.0

func Round(x float64, place int32) float64

Round 四舍五入.

func RsaPrivateDecrypt

func RsaPrivateDecrypt(privateKeyBytes, cipherBytes []byte) (textBytes []byte, err error)

RsaPrivateDecrypt 解析rsa私钥,参数privateKeyStr必须是hex、base64或者是pem编码.

func RsaPublicEncrypt

func RsaPublicEncrypt(publicKeyBytes, textBytes []byte) ([]byte, error)

RsaPublicEncrypt Rsa公钥加密,参数publicKeyStr必须是hex、base64或者是pem编码.

func RsaPublicKeyToJWK added in v1.3.8

func RsaPublicKeyToJWK(pub *rsa.PublicKey) ([]byte, error)

func SM2PublicEncrypt added in v1.3.6

func SM2PublicEncrypt(publicKeyBytes, textBytes []byte) ([]byte, error)

SM2PublicEncrypt sm2公钥加密,参数publicKeyStr必须是hex、base64或者是pem编码.

func SignByRSA

func SignByRSA(key *rsa.PrivateKey, licenseBytes []byte) (license string, err error)

SignByRSA 使用rsa私钥对象指针签名字符串,返回base64编码的license.

func SignByRSABytes

func SignByRSABytes(key, licenseBytes []byte) (string, error)

SignByRSABytes 使用rsa私钥签名字符串,返回base64编码的license.

func SignBySM2

func SignBySM2(privateKey *sm2.PrivateKey, licenseBytes []byte) (license string, err error)

SignBySM2 使用sm2私钥对象指针签名字符串,返回base64编码的license.

func SignBySM2Bytes

func SignBySM2Bytes(privateKey, licenseBytes []byte) (license string, err error)

SignBySM2Bytes 使用sm2私钥签名字符串,返回base64编码的license.

func StrToBytes

func StrToBytes(str string) []byte

StrToBytes string转[]byte.

func StringReplaceIgnoreCase

func StringReplaceIgnoreCase(text, source, target string) string

StringReplaceIgnoreCase 忽略大小写替换字符串.

func TRACE added in v1.2.0

func TRACE(pattern string, handlerFunc http.HandlerFunc)

func TimeToStr

func TimeToStr(t time.Time, format ...string) string

TimeToStr 返回时间的字符串格式.

func TimestampToStr

func TimestampToStr(t int64, format ...string) string

TimestampToStr Timestamp将unix时间转为时间字符串.

func VerifyByRSA

func VerifyByRSA(publicKeyBase64, licenseCode string) (license string, valid bool, err error)

VerifyByRSA 使用rsa公钥验证签名的license.

func VerifyBySM2

func VerifyBySM2(publicKeyBase64, licenseCode string) (license string, valid bool, err error)

VerifyBySM2 使用sm2公钥验证签名的license.

func VerifyJwtSign added in v1.3.8

func VerifyJwtSign(ciphertext, key []byte) (json.RawMessage, error)

VerifyJwtSign verify jwt sign text , key is hmac key or rsa/ecdsa public key

func VerifyJwtSignByEcdsa added in v1.3.8

func VerifyJwtSignByEcdsa(ciphertext []byte, publicKey *ecdsa.PublicKey) (json.RawMessage, error)

func VerifyJwtSignByHmacHash added in v1.3.8

func VerifyJwtSignByHmacHash(ciphertext, key []byte) (json.RawMessage, error)

func VerifyJwtSignByRsa added in v1.3.8

func VerifyJwtSignByRsa(ciphertext []byte, publicKey *rsa.PublicKey) (json.RawMessage, error)

func WithContext added in v1.2.0

func WithContext(ctx context.Context, n uint, interval time.Duration, fn func() error) (err error)

WithContext stops retrying when the context is done.

Types

type Audience added in v1.3.5

type Audience []string

Audience is a special claim that may either be a single string or an array of strings, as per the RFC 7519.

func (Audience) MarshalJSON added in v1.3.5

func (a Audience) MarshalJSON() ([]byte, error)

MarshalJSON implements a marshaling function for "aud" claim.

func (*Audience) UnmarshalJSON added in v1.3.5

func (a *Audience) UnmarshalJSON(b []byte) error

UnmarshalJSON implements an unmarshaling function for "aud" claim.

type BlockStreamMode added in v1.3.5

type BlockStreamMode string
const (
	CTR BlockStreamMode = "CTR"
	CFB BlockStreamMode = "CFB"
	OFB BlockStreamMode = "OFB"
	RC4 BlockStreamMode = "RC4"
)

type Codec added in v1.3.5

type Codec interface {
	Encode(key, plaintext []byte) ([]byte, error)
	Decode(key, ciphertext []byte) ([]byte, error)
}

func NewCookieCodec added in v1.3.5

func NewCookieCodec(hashKey, blockKey []byte) Codec

func NewJwtCodec added in v1.3.5

func NewJwtCodec(alg string) Codec

type GobEncoder added in v1.3.5

type GobEncoder struct{}

GobEncoder encodes cookie values using encoding/gob. This is the simplest encoder and can handle complex types via gob.Register.

func (GobEncoder) Deserialize added in v1.3.5

func (e GobEncoder) Deserialize(src []byte, dst interface{}) error

Deserialize decodes a value using gob.

func (GobEncoder) Serialize added in v1.3.5

func (e GobEncoder) Serialize(src interface{}) ([]byte, error)

type HTTPReceiveFile added in v1.3.10

type HTTPReceiveFile struct {
	MaxReceiveSize int64       //  输入|输出: 最大文件
	DstDirMode     fs.FileMode //  输入|输出: 文件夹名
	DstFileMode    fs.FileMode //  输入|输出: 文件夹名
	DstDir         string      //  输入|输出: 文件夹名
	DstFilename    string      //  输入|输出: 文件名
	FieldName      string      // 输入: 字段名
	FileMIME       string      // 输出: 文件MIME
	TotalSize      int64       // 输出: 总大小
	Hash           hash.Hash   // 输入: hash函数,默认 sha256
	Checksum       string      // 输出: checksum
	// contains filtered or unexported fields
}

func (*HTTPReceiveFile) String added in v1.3.10

func (h *HTTPReceiveFile) String() string
type Header struct {
	Algorithm   string `json:"alg,omitempty"`
	ContentType string `json:"cty,omitempty"`
	KeyID       string `json:"kid,omitempty"`
	Type        string `json:"typ,omitempty"`
}

type IDGenerator added in v1.2.0

type IDGenerator interface {
	Snowflake() snowflake.ID
	XID() xid.ID
	UUID4() uuid.UUID
	SInt64() int64
	SString() string
	XString() string
	UString() string
	RandString(int) string
}

type JSONEncoder added in v1.3.5

type JSONEncoder struct{}

func (JSONEncoder) Deserialize added in v1.3.5

func (e JSONEncoder) Deserialize(src []byte, dst interface{}) error

Deserialize decodes a value using encoding/json.

func (JSONEncoder) Serialize added in v1.3.5

func (e JSONEncoder) Serialize(src interface{}) ([]byte, error)

Serialize encodes a value using encoding/json.

type JWK added in v1.3.8

type JWK struct {
	KTY       string `json:"kty"`
	KID       string `json:"kid"`
	Use       string `json:"use"`
	Algorithm string `json:"alg"`
	N         string `json:"n"`
	E         string `json:"e"`
}

type JwtPayload added in v1.3.8

type JwtPayload struct {
	JTI       string        `json:"jti"`
	IAT       int           `json:"iat"`
	EXP       int           `json:"exp"`
	NBF       int           `json:"nbf"`
	ISS       string        `json:"iss"`
	Sub       string        `json:"sub"`
	Aud       string        `json:"aud"`
	Roles     []interface{} `json:"roles"`
	AuthType  string        `json:"authType"`
	UserId    string        `json:"userId"`
	SubjectId string        `json:"subjectId"`
	Email     string        `json:"email"`
}

type Payload added in v1.3.5

type Payload struct {
	Issuer         string   `json:"iss,omitempty"`
	Subject        string   `json:"sub,omitempty"`
	Audience       Audience `json:"aud,omitempty"`
	ExpirationTime *Time    `json:"exp,omitempty"`
	NotBefore      *Time    `json:"nbf,omitempty"`
	IssuedAt       *Time    `json:"iat,omitempty"`
	JWTID          string   `json:"jti,omitempty"`
}

Payload is a JWT payload according to the RFC 7519.

type RSABit added in v1.3.0

type RSABit int
const (
	RSA1024 RSABit = 1024
	RSA2048 RSABit = 2048
)

type ReceiveFileOption added in v1.3.10

type ReceiveFileOption func(*HTTPReceiveFile)

func WithReceiveFileDstDir added in v1.3.10

func WithReceiveFileDstDir(dstDir string) ReceiveFileOption

WithReceiveFileDstDir 接收文件夹路径,默认是当前工作路径

func WithReceiveFileDstDirMode added in v1.3.10

func WithReceiveFileDstDirMode(dstDirMode fs.FileMode) ReceiveFileOption

func WithReceiveFileDstFileMode added in v1.3.10

func WithReceiveFileDstFileMode(dstFileMode fs.FileMode) ReceiveFileOption

func WithReceiveFileDstFilename added in v1.3.10

func WithReceiveFileDstFilename(dstFilename string) ReceiveFileOption

func WithReceiveFileDstFilenameFunc added in v1.3.10

func WithReceiveFileDstFilenameFunc(fn func(*multipart.FileHeader) string) ReceiveFileOption

func WithReceiveFileHash added in v1.3.10

func WithReceiveFileHash(hash hash.Hash) ReceiveFileOption

func WithReceiveFileHashMD5 added in v1.3.10

func WithReceiveFileHashMD5() ReceiveFileOption

func WithReceiveFileHashSha1 added in v1.3.10

func WithReceiveFileHashSha1() ReceiveFileOption

func WithReceiveFileHashSha512 added in v1.3.10

func WithReceiveFileHashSha512() ReceiveFileOption

func WithReceiveFileMaxReceiveSize added in v1.3.10

func WithReceiveFileMaxReceiveSize(maxReceiveSize int64) ReceiveFileOption

WithReceiveFileMaxReceiveSize 最小单位是字节Bytes

type SecretKeyFormatType

type SecretKeyFormatType int
const (
	PKCS8 SecretKeyFormatType = 1
	PKCS1 SecretKeyFormatType = 2
)

func SecretKeyFormatTypeParse

func SecretKeyFormatTypeParse(v int) SecretKeyFormatType

type SecretKeyLengthType

type SecretKeyLengthType int
const (
	RSA SecretKeyLengthType = 1
	M2  SecretKeyLengthType = 2
)

func SecretKeyLengthTypeParse

func SecretKeyLengthTypeParse(v int) SecretKeyLengthType

type Serializer added in v1.3.5

type Serializer interface {
	Serialize(src interface{}) ([]byte, error)
	Deserialize(src []byte, dst interface{}) error
}

type Time added in v1.1.0

type Time struct {
	time.Time
}

Time is the allowed format for time, as per the RFC 7519.

func NumericDate added in v1.1.0

func NumericDate(tt time.Time) *Time

NumericDate is a resolved Unix time.

func (Time) MarshalJSON added in v1.1.0

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements a marshaling function for time-related claims.

func (*Time) UnmarshalJSON added in v1.1.0

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements an unmarshaling function for time-related claims.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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