convert

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 3 Imported by: 0

README

Convert

Description

A set of conversion functions and tools

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyListToStringList

func AnyListToStringList(list *[]any) []string

AnyListToStringList - Convert an []any list to []string

func BoolErrToStringErr

func BoolErrToStringErr(n bool, err error) (string, error)

BoolErrToStringErr - given a bool and error, return its string, error. (useful as a wrapper)

func BytesToKilobytes

func BytesToKilobytes(b int) int

BytesToKilobytes - convert the number of bytes to a number of kilobytes

func DecodeHexByte

func DecodeHexByte(value *byte, c1, c2 byte) (ok bool)

DecodeHexByte - Decode a hexadecimal byte

func DecodeHexByte64

func DecodeHexByte64(value *[8]byte, src []byte) (ok bool)

DecodeHexByte64 - decodes two sets of hexadecimal bytes and returns the resulting byte values

func DecodeHexChar

func DecodeHexChar(value *byte, c byte) (ok bool)

DecodeHexChar - decode a single byte representing a hexadecimal digit and return the numeric equivalent as a byte

func DecodeHexUint16

func DecodeHexUint16(value *uint16, src []byte) (ok bool)

DecodeHexUint16 - Decode a hexadecimal 2-byte slice into a 16-bit unsigned-integer

func DecodeHexUint32

func DecodeHexUint32(value *uint32, src []byte) (ok bool)

DecodeHexUint32 - decode a 32-bit hexidecimal byte string as uint32

func ErrorToString

func ErrorToString(err error) string

ErrorToString - Safely turn an error into a string

func Float64ErrToStringErr

func Float64ErrToStringErr(n float64, err error) (string, error)

Float64ErrToStringErr - given a float64 and error, return its string, error. (useful as a wrapper)

func Int64ToIntSafe

func Int64ToIntSafe(num int64) (int, error)

Int64ToIntSafe - safely convert int64 to integer

func IntErrToStringErr

func IntErrToStringErr(n int, err error) (string, error)

IntErrToStringErr - given an int and error, return its string, error. (useful as a wrapper)

func IntToStringFuncWrapper

func IntToStringFuncWrapper(fn func() (int, error)) (string, error)

IntToStringFuncWrapper - convert an integer to a string

func MegabytesToKiloBytes

func MegabytesToKiloBytes(n int) int

MegabytesToKiloBytes - Given an integer (in Megabytes) return the value in Kilobytes)

func PutByteHex

func PutByteHex(hexOutput, byteSource []byte)

PutByteHex - store a byte array as a hex byte array

func PutUint16Hex

func PutUint16Hex(b []byte, v uint16)

PutUint16Hex - Write uint16 to a byte array as hex

func PutUint32Hex

func PutUint32Hex(b []byte, v uint32)

PutUint32Hex - write a 32-bit value into a hexidecimal byte array

func PutUint64Hex

func PutUint64Hex(b []byte, v uint64)

PutUint64Hex - write a 64-bit value into a hexadecimal byte array

func StringListToAnyList

func StringListToAnyList(list *[]string) []any

StringListToAnyList - Convert a list of strings to an []any list

func UnsafeAtoI

func UnsafeAtoI(a string) (i int)

UnsafeAtoI - ignore any error converting string to integer (0 on error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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