utils

package
v0.0.0-...-11acf48 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package utils contains utility functions used in the coniks-go library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNthBit

func GetNthBit(bs []byte, offset uint32) bool

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

func LongToBytes(num int64) []byte

LongToBytes converts an int64 variable to byte array in little endian format.

func ResolvePath

func ResolvePath(file, other string) string

ResolvePath returns the absolute path of file. This will use other as a base path if file is just a file name.

func ToBits

func ToBits(bs []byte) []bool

ToBits converts a slice of bytes into a slice of bits. In each byte, the bits are ordered MSB to LSB.

func ToBytes

func ToBytes(bits []bool) []byte

ToBytes converts a slice of bits into a slice of bytes. In each byte, the bits are ordered MSB to LSB.

func UInt32ToBytes

func UInt32ToBytes(num uint32) []byte

UInt32ToBytes converts an uint32 variable to byte array in little endian format.

func ULongToBytes

func ULongToBytes(num uint64) []byte

ULongToBytes converts an uint64 variable to byte array in little endian format.

func WithDB

func WithDB(f func(kv.DB))

WithDB is used to run tests with a database backend. It creates a temporary directory named "merkletree" in the system's tmp directory and then creates an empty key-value database. This temporary directory will be removed after this function returns.

func WriteFile

func WriteFile(filename string, buf []byte, perm os.FileMode) error

WriteFile writes buf to a file whose path is indicated by filename.

Types

This section is empty.

Jump to

Keyboard shortcuts

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