Documentation
¶
Index ¶
- func Base64Decode(encoded string) ([]byte, error)
- func Base64Encode(data []byte) string
- func Decrypt(signKey string, ciphertext string) (string, error)
- func DerefString(s *string) string
- func Ed25519Verify(publicKey, message, signature []byte) bool
- func Encrypt(signKey string, plaintext string) (string, error)
- func GenerateUniqueIDSimple() string
- func GetFromContext[T any](c *gin.Context, key string) (T, bool)
- func GetSessionOptions(maxAge int) sessions.Options
- func IsLocalhost(urlStr string) bool
- func Request(ctx context.Context, method, url string, body io.Reader, ...) (*http.Response, error)
- func SetToContext[T any](c *gin.Context, key string, value T)
- func ValidateAmount(amount decimal.Decimal) error
- func ValidateRates(rates ...decimal.Decimal) error
- type Response
- type ResponseAny
- type StringArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt 使用 SignKey 解密字符串数据 signKey: 64 字符 hex 编码的密钥(对应 32 字节,用于 AES-256) ciphertext: base64 编码的密文 return: 解密后的明文字符串
func Ed25519Verify ¶
Ed25519Verify 验证 Ed25519 签名 publicKey: 32 字节的公钥(已解码的二进制格式) message: 待验证的原始消息 signature: 64 字节的签名(已解码的二进制格式) return: 签名是否有效
func Encrypt ¶
Encrypt 使用 SignKey 加密字符串数据 signKey: 64 字符 hex 编码的密钥(对应 32 字节,用于 AES-256) plaintext: 要加密的明文字符串 return: base64 编码的密文
func GenerateUniqueIDSimple ¶
func GenerateUniqueIDSimple() string
GenerateUniqueIDSimple 生成 64 位唯一标识符
func GetFromContext ¶
GetFromContext 从上下文获取指定类型的值
func GetSessionOptions ¶
func SetToContext ¶
SetToContext 设置值到上下文
func ValidateAmount ¶
ValidateAmount 验证金额:必须大于0,且小数位数不超过2位
func ValidateRates ¶
ValidateRates 所有 rate 必须在 [0, 1] 范围内,且小数位数不超过2位
Types ¶
type ResponseAny ¶
type ResponseAny struct {
ErrorMsg string `json:"error_msg" example:""`
Data interface{} `json:"data"`
}
ResponseAny 用于 Swagger 文档的响应类型(非泛型) swag 不支持泛型,使用此类型替代 Response[T]
type StringArray ¶
type StringArray []string
StringArray custom type for handling JSON arrays
func (*StringArray) Scan ¶
func (sa *StringArray) Scan(value interface{}) error
Click to show internal directories.
Click to hide internal directories.