utils

package
v0.0.0-...-509ba17 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const UINT32_MAX_NUMBER = 4294967295

Variables

This section is empty.

Functions

func AppendBytesToSlice

func AppendBytesToSlice(buf []byte, newElement []byte) []byte

AppendBytesToSlice takes a slice of bytes as the first argument and another slice of bytes as the second argument. It returns a single slice with the second argument appended to the first.

Parameters:

  • buf: The original slice of bytes.
  • newElement: The slice of bytes to append to the original slice.

Returns:

  • A new slice of bytes containing the original slice followed by the appended slice.

func BytesToUint32

func BytesToUint32(i []byte) uint32

BytesToUint32 takes a slice of bytes and returns its conversion to uint32.

Parameters:

  • i: A slice of 4 bytes to be converted to a uint32 value.

Returns:

  • A uint32 value represented by the byte slice in little-endian format.

func CalculateCRC

func CalculateCRC(data []byte) uint32

CalculateCRC returns the checksum of the data provided by the argument using the IEEE polynomial.

Parameters:

  • data: A slice of bytes for which the CRC checksum will be calculated.

Returns:

  • A uint32 value representing the CRC checksum.

func IntToUint32

func IntToUint32(i int) (uint32, error)

IntToUint32 takes an integer and returns its conversion to uint32.

Parameters:

  • i: An integer value to be converted to uint32.

Returns:

  • A uint32 value if the conversion is successful.
  • An error if the integer is negative or exceeds the maximum value of uint32.

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

Uint32ToBytes takes a uint32 value and returns its conversion to a byte slice.

Parameters:

  • i: A uint32 value to be converted to a byte slice.

Returns:

  • A slice of 4 bytes representing the uint32 value in little-endian format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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