Documentation ¶
Overview ¶
Package utils contains utility functions used in the coniks-go library.
Index ¶
- func GetNthBit(bs []byte, offset uint32) bool
- func LongToBytes(num int64) []byte
- func ResolvePath(file, other string) string
- func ToBits(bs []byte) []bool
- func ToBytes(bits []bool) []byte
- func UInt32ToBytes(num uint32) []byte
- func ULongToBytes(num uint64) []byte
- func WithDB(f func(kv.DB))
- func WriteFile(filename string, buf []byte, perm os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNthBit ¶
GetNthBit finds the bit in the byte array bs at offset, and determines whether it is 1 or 0. It returns true if the nth bit is 1, false otherwise.
func LongToBytes ¶
LongToBytes converts an int64 variable to byte array in little endian format.
func ResolvePath ¶
ResolvePath returns the absolute path of file. This will use other as a base path if file is just a file name.
func ToBits ¶
ToBits converts a slice of bytes into a slice of bits. In each byte, the bits are ordered MSB to LSB.
func ToBytes ¶
ToBytes converts a slice of bits into a slice of bytes. In each byte, the bits are ordered MSB to LSB.
func UInt32ToBytes ¶
UInt32ToBytes converts an uint32 variable to byte array in little endian format.
func ULongToBytes ¶
ULongToBytes converts an uint64 variable to byte array in little endian format.
Types ¶
This section is empty.