util

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxWorkId   = -1 ^ (-1 << numWorkerBits)
	MaxSequence = -1 ^ (-1 << numSequenceBits)
)

Variables

This section is empty.

Functions

func ByteIndexOf

func ByteIndexOf(source []byte, targetByte []byte) int

ByteIndexOf Find the coordinates of the corresponding data from byte[]

func BytesToInt

func BytesToInt(b []byte, start int, length int) int

BytesToInt byte[] to int

func BytesToString

func BytesToString(val []byte) string

BytesToString byte[] to string

func CopyOfRange

func CopyOfRange(src []byte, srcOffset int, size int) ([]byte, error)

CopyOfRange Copy the data of the specified range in the array

func DeSerialization

func DeSerialization(source []byte, dst interface{}) error

DeSerialization Deserialize source to dst

func Decryption

func Decryption(source []byte, iv []byte, key []byte) ([]byte, error)

Decryption Decrypt source to dst

func DecryptionForString

func DecryptionForString(source string, iv string, key string) (string, error)

DecryptionForString Decrypt source to dst

func Encryption

func Encryption(data []byte, iv []byte, key []byte) ([]byte, error)

Encryption Encrypt data to []byte

func EncryptionToString

func EncryptionToString(data string, iv string, key string) (string, error)

EncryptionToString Encrypt data to string

func Get

func Get(reqUrl string, param interface{}) (*http.Response, error)

Get Sending get requests

func IntToBytes

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

IntToBytes int to byte[]

func Match

func Match(source string, reg string) bool

Match Determines if the first parameter matches the second parameter with a wildcard

func ParseStruct

func ParseStruct(jsonString string, result interface{}) error

ParseStruct Json string to struct

func RequestBody

func RequestBody(reqUrl string, method string, header map[string]string, reqBody io.Reader) (*http.Response, error)

RequestBody Initiating a request with body parameters

func Serialization

func Serialization(data interface{}) ([]byte, error)

Serialization Serialize data to []byte

func StrToBytes

func StrToBytes(val string) []byte

StrToBytes string to byte[]

func SubBytes

func SubBytes(source []byte, startIndex int, endIndex int) ([]byte, error)

SubBytes Extract the byte[] between the specified coordinates

func ToJSONString

func ToJSONString(stc interface{}) (string, error)

ToJSONString Structs to json strings

func ToString

func ToString(value interface{}) string

ToString Unbox interface{} into string

Types

type SnowFlake

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

func New

func New(workerId uint32) (*SnowFlake, error)

New returns a new snowflake node that can be used to generate snowflake

func (*SnowFlake) Generate

func (sf *SnowFlake) Generate() (uint64, error)

Generate Next creates and returns a unique snowflake ID

Jump to

Keyboard shortcuts

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