internal

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolFromByteArray

func BoolFromByteArray(v []byte) (bool, error)

BoolFromByteArray converts a BigEndian byte array to a bool

func BoolToByteArray

func BoolToByteArray(v bool) []byte

BoolToByteArray converts a bool to a byte array

func ConcatByteArrays

func ConcatByteArrays(arrays ...[]byte) []byte

ConcatByteArrays concatenates a number of byte arrays

func GenerateFileWithTestData

func GenerateFileWithTestData(filePath string, data []byte) (*os.File, error)

GenerateFileWithTestData creates a file at the given filePath if it does not exist and adds the given data overwriting any pre-existing data

func GetFileSize added in v0.1.0

func GetFileSize(file *os.File) (uint64, error)

GetFileSize computes the file size of the given file

func GetHash

func GetHash(key []byte, blockLength uint64) uint64

GetHash generates the hash of the key for the given block length to get the position in the block that the given key corresponds to

func PathExists added in v0.1.0

func PathExists(path string) (bool, error)

PathExists checks to see if a given path exists

func SafeSlice

func SafeSlice(data []byte, start uint64, end uint64, maxLength uint64) ([]byte, error)

SafeSlice slices a slice safely, throwing an error if it goes out of bounds

func Uint16FromByteArray

func Uint16FromByteArray(v []byte) (uint16, error)

Uint16FromByteArray converts a BigEndian byte array to a uint16

func Uint16ToByteArray

func Uint16ToByteArray(v uint16) []byte

Uint16ToByteArray converts a uint16 to a BigEndian byte array

func Uint32FromByteArray

func Uint32FromByteArray(v []byte) (uint32, error)

Uint32FromByteArray converts a BigEndian byte array to a uint32

func Uint32ToByteArray

func Uint32ToByteArray(v uint32) []byte

Uint32ToByteArray converts a uint32 to a BigEndian byte array

func Uint64FromByteArray

func Uint64FromByteArray(v []byte) (uint64, error)

Uint64FromByteArray converts a BigEndian byte array to a uint64

func Uint64ToByteArray

func Uint64ToByteArray(v uint64) []byte

Uint64ToByteArray converts a uint64 to a BigEndian byte array

func ValidateBounds

func ValidateBounds(actualLower uint64, actualUpper uint64, expectedLower uint64, expectedUpper uint64, msg string) error

ValidateBounds checks if the given range is within bounds or else returns an InvalidData error FIXME: Add test for this

Types

This section is empty.

Directories

Path Synopsis
entries

Jump to

Keyboard shortcuts

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