tools

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DIGITS64 []byte = []byte("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_")

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

AES解密

func AesEncrypt

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

AES加密,CBC

func BoolPtr

func BoolPtr(f bool) *bool

func BytesToUInt64

func BytesToUInt64(buf []byte) uint64

func DecodeInt

func DecodeInt(str string) (int64, error)

func EncodeInt

func EncodeInt(num int64) (string, error)

func GenerateUUID

func GenerateUUID() uuid.UUID

func GenerateUUIDBytes

func GenerateUUIDBytes() []byte

func GenerateUUIDShort11

func GenerateUUIDShort11() string

func GenerateUUIDShort22

func GenerateUUIDShort22() string

func GenerateUUIDString

func GenerateUUIDString() string

func GetConversationId

func GetConversationId(fromId, targetId string, channelType int32) string

func HashStr

func HashStr(str string) uint32

func HmacSha1

func HmacSha1(key []byte, data string) []byte

func HmacSha256

func HmacSha256(key []byte, data string) []byte

func HttpDo

func HttpDo(method, url string, header map[string]string, body string) (string, int, error)

func HttpDoBytes

func HttpDoBytes(method, url string, header map[string]string, body string) ([]byte, int, error)

func HttpDoBytesWithTimeout

func HttpDoBytesWithTimeout(method, url string, header map[string]string, body string, timeout time.Duration) ([]byte, int, error)

func Int2String

func Int2String(val int64) string

func IntPtr

func IntPtr(i int) *int

func JsonMarshal

func JsonMarshal(obj interface{}) ([]byte, error)

func JsonUnMarshal

func JsonUnMarshal(bytes []byte, obj interface{}) error

func MapToStruct

func MapToStruct[T any](m map[string]interface{}) T

func MaskEmail

func MaskEmail(email string) string

func MaskPhone

func MaskPhone(phone string) string

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func ParseFloat

func ParseFloat(val string) (float64, error)

func ParseInt

func ParseInt(value string) (int, error)

func ParseInt64

func ParseInt64(value string) (int64, error)

func PbMarshal

func PbMarshal(obj proto.Message) ([]byte, error)

func PbUnMarshal

func PbUnMarshal(bytes []byte, typeScope proto.Message) error

func RandInt

func RandInt(n int) int

func RandIntn

func RandIntn(i int) int

func RandStr

func RandStr(n int) string

func SHA1

func SHA1(s string) string

func ShortCut

func ShortCut(str string) string

func ShortMd5

func ShortMd5(str string) string

func String2Int64

func String2Int64(str string) (int64, error)

func ToInt

func ToInt(str string) int

func ToJson

func ToJson(val interface{}) string

func UUID2ShortString

func UUID2ShortString(uuid uuid.UUID) string

func UUIDStringByBytes

func UUIDStringByBytes(bytes []byte) (string, error)

Types

type HttpStream

type HttpStream struct {
	// contains filtered or unexported fields
}

func CreateStream

func CreateStream(method, url string, headers map[string]string, body string) (*HttpStream, int, error)

func (*HttpStream) Close

func (stream *HttpStream) Close()

func (*HttpStream) Receive

func (stream *HttpStream) Receive() (string, error)

type N3d

type N3d struct {
	// contains filtered or unexported fields
}
var IdEncryptor *N3d

func NewN3d

func NewN3d(lower, upper int64) (*N3d, error)

func (*N3d) Decrypt

func (n *N3d) Decrypt(str string) (int64, error)

func (*N3d) Encrypt

func (n *N3d) Encrypt(num int64) (string, error)

type SegmentatedLocks

type SegmentatedLocks struct {
	// contains filtered or unexported fields
}

func NewSegmentatedLocks

func NewSegmentatedLocks(num int) *SegmentatedLocks

func (*SegmentatedLocks) GetLocks

func (seg *SegmentatedLocks) GetLocks(strs ...string) *sync.RWMutex

Jump to

Keyboard shortcuts

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