util

package
v0.0.0-...-8c0c3db Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bits8ToByte

func Bits8ToByte(bitArray []Bit) byte

Bits8ToByte : convert 8 bits to 1 byte

func BitsToByte

func BitsToByte(bitArray []Bit, bitLen int) byte

BitsToByte : convert bits to 1 byte

func ByteArrayToIntArray

func ByteArrayToIntArray(data []byte) (dataInts []int)

func GetZeroBytes

func GetZeroBytes(zeroCount int) []byte

GetZeroBytes :Get a zero byte array by zeroCount

func ImageToBase64Url

func ImageToBase64Url(imageType Base64URLImageType, imageByte []byte) string

ImageToBase64Url : data:image/gif;base64, //gif data:image/png;base64, // png data:image/jpeg;base64,//jpeg data:image/svg+xml;base64 //svg

func IntArrayToByteArray

func IntArrayToByteArray(data []int) (dataBytes []byte)

IntArrayToByteArray :convert int array to byte array

func IntIn

func IntIn(target int, intArray []int) bool

IntIn :Check target int is or not in intArray

func IteratorStringByte

func IteratorStringByte(data string) <-chan rune

IteratorStringByte : iterate by rune

func IteratorTwoByte

func IteratorTwoByte(data string) <-chan uint16

IteratorTwoByte : iterate by two-byte param: data,two-byte strings

func IteratorTwoByteEach

func IteratorTwoByteEach(data string) <-chan []uint16

func Parallel

func Parallel(start, stop int, fn func(<-chan int))

Parallel parallel processes the data in separate goroutines.

func RunCmd

func RunCmd(command string, args ...string) (result string, err error)

func StrIn

func StrIn(target string, strArray []string) bool

StrIn :Check target string is or not in strArray

Types

type Base64URLImageType

type Base64URLImageType string
const (
	GifType  Base64URLImageType = "gif"
	PngType  Base64URLImageType = "png"
	JpegType Base64URLImageType = "jpeg"
	SvgType  Base64URLImageType = "svg+xml"
)

type Bit

type Bit = byte

Bit : use byte to represent bit. value is 0/1

func ByteArrayTo8BitArray

func ByteArrayTo8BitArray(data []byte) (dataBits []Bit)

ByteArrayTo8BitArray :convert byte array to 8 bit array(1 byte split to 8 bit save in Bit array) e.g. : input : {byte(1)} result: {0,0,0,0,0,0,0,1}

func ByteArrayTo8BitArrayWithCount

func ByteArrayTo8BitArrayWithCount(data []byte, bitsCount int) (dataBits []Bit)

ByteArrayTo8BitArrayWithCount :convert byte array to 8 bit array(1 byte split to 8 bit save in Bit array) e.g. : input : {byte(1)} result: {0,0,0,0,0,0,0,1}

param data: input byte array param bitsCount: total bit count for return

func IntTo8BitArray

func IntTo8BitArray(i int) []Bit

IntTo8BitArray : int change to binary array in []byte, and byte is 8-bit

func IntToBinary

func IntToBinary(i uint16) []Bit

IntToBinary : int change to binary array in []byte , array not full 8-bit

type DataStream

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

func NewDataStream

func NewDataStream(capacity int) *DataStream

func (*DataStream) AddBit

func (ds *DataStream) AddBit(b []Bit, count int)

func (*DataStream) AddIntBit

func (ds *DataStream) AddIntBit(i int, count int)

AddIntBit :Add int to []byte into DataStream

func (*DataStream) AddIntBit16

func (ds *DataStream) AddIntBit16(i uint16, count int)

AddIntBit16 :Add int to []byte into DataStream

func (*DataStream) Clean

func (ds *DataStream) Clean()

func (*DataStream) GetCount

func (ds *DataStream) GetCount() int

func (*DataStream) GetData

func (ds *DataStream) GetData() []Bit

func (*DataStream) IteratorByte

func (ds *DataStream) IteratorByte() <-chan byte

IteratorByte :Iterate the data bits to Byte(8-bit). return byte chan.

type Module

type Module = byte

Module : use byte to represent symbol module. value is 0/1

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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