util

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2017 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound indicates the given key was not found.
	ErrKeyNotFound = errors.New("Key not found")
	// ErrKeyLocked menas that the key cannot be modified, as it's locked by another process.
	ErrKeyLocked = errors.New("Key is locked")
	// ErrInvalidKey signals that the given key name is invalid.
	ErrInvalidKey = errors.New("Invalid key name")
	// ErrTypeMismatch signals that the type of value being requested is unexpected.
	ErrTypeMismatch = errors.New("Type mismatch")
	// ErrListEmpty signals that the List is empty.
	ErrListEmpty = errors.New("List is empty")
	// ErrListIndexOutOfRange signals that the given index is out of range of the list.
	ErrListIndexOutOfRange = errors.New("Index out of range")
	// ErrHashFieldNotFound signals that the hash does not have the given field.
	ErrHashFieldNotFound = errors.New("Hash field does not exist")
)
View Source
var ZeroByte = []byte{0}

ZeroByte represents a single zero byte in a byte slice.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString efficiently converts a byte slice to a string without allocating any additional memory.

func ListStringToBytes

func ListStringToBytes(lst []string) [][]byte

ListStringToBytes converts a []string to [][]byte.

func ListValueToBytes

func ListValueToBytes(lst []Value) [][]byte

ListValueToBytes converts a []Value to [][]byte.

func MapBoolToMapBytes

func MapBoolToMapBytes(h map[string]bool) map[string][]byte

MapBoolToMapBytes converts a map[string]string to map[string][]byte.

func MapBytesToValues

func MapBytesToValues(h map[string][]byte) map[string]Value

MapBytesToValues converts a map[string][]byte to map[string]Value.

func MapFloatToMapBytes

func MapFloatToMapBytes(h map[string]float64) map[string][]byte

MapFloatToMapBytes converts a map[string]string to map[string][]byte.

func MapIntToMapBytes

func MapIntToMapBytes(h map[string]int64) map[string][]byte

MapIntToMapBytes converts a map[string]string to map[string][]byte.

func MapStringToMapBytes

func MapStringToMapBytes(h map[string]string) map[string][]byte

MapStringToMapBytes converts a map[string]string to map[string][]byte.

func MapValueToMapBytes

func MapValueToMapBytes(h map[string]Value) map[string][]byte

MapValueToMapBytes converts a map[string]Value to map[string][]byte.

func NewSelfCerts

func NewSelfCerts(orgName string) (cfg *tls.Config, err error)

NewSelfCerts generates new self-signed certificates.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes efficiently converts a string to a byte slice without allocating any additional memory.

Types

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value object.

func ListStringToValues

func ListStringToValues(lst []string) []Value

ListStringToValues converts a []string to []Value.

func ListToValues

func ListToValues(lst [][]byte) []Value

ListToValues converts a [][]byte to []Value.

func NewValue

func NewValue(t interface{}) Value

NewValue returns a new Value object.

func (Value) Bool

func (v Value) Bool() (bool, error)

Bool returns the Value as bool.

func (Value) Bytes

func (v Value) Bytes() ([]byte, error)

Bytes returns the Value as a byte slice.

func (Value) Duration

func (v Value) Duration() (time.Duration, error)

Duration returns the Value as a Duration.

func (Value) Error

func (v Value) Error() error

Error returns the error associated with this Value, if one exists.

func (Value) Float

func (v Value) Float() (float64, error)

Float returns the Value as a flat64.

func (Value) Int

func (v Value) Int() (int64, error)

Int returns the Value as an int64.

func (Value) List

func (v Value) List() ([]Value, error)

List returns the Value as a List.

func (Value) Map

func (v Value) Map() (map[string]Value, error)

Map returns the Value as a Map.

func (Value) Proto

func (v Value) Proto(pb proto.Message) error

Proto returns the given ProtoMessage.

func (Value) RawBytes

func (v Value) RawBytes() []byte

RawBytes returns the Value as a byte slice, ignoring any error.

func (Value) String

func (v Value) String() (string, error)

String returns the Value as a string.

func (Value) Time

func (v Value) Time() (time.Time, error)

Time returns the Value as a Time.

Jump to

Keyboard shortcuts

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