Documentation

Overview

    package kv provides basic key and value types.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Key

    type Key string

      Key represents the key part in key-value pairs. It's a string. The allowed character set in the key depends on the use of the key.

      func (Key) Array

      func (k Key) Array(v interface{}) KeyValue

        Array creates a KeyValue instance with a ARRAY Value.

        If creating both key and a array value at the same time, then instead of calling kv.Key(name).String(value) consider using a convenience function provided by the api/key package - key.Array(name, value).

        func (Key) Bool

        func (k Key) Bool(v bool) KeyValue

          Bool creates a KeyValue instance with a BOOL Value.

          If creating both key and a bool value at the same time, then instead of calling kv.Key(name).Bool(value) consider using a convenience function provided by the api/key package - key.Bool(name, value).

          func (Key) Defined

          func (k Key) Defined() bool

            Defined returns true for non-empty keys.

            func (Key) Float32

            func (k Key) Float32(v float32) KeyValue

              Float32 creates a KeyValue instance with a FLOAT32 Value.

              If creating both key and a float32 value at the same time, then instead of calling kv.Key(name).Float32(value) consider using a convenience function provided by the api/key package - key.Float32(name, value).

              func (Key) Float64

              func (k Key) Float64(v float64) KeyValue

                Float64 creates a KeyValue instance with a FLOAT64 Value.

                If creating both key and a float64 value at the same time, then instead of calling kv.Key(name).Float64(value) consider using a convenience function provided by the api/key package - key.Float64(name, value).

                func (Key) Int

                func (k Key) Int(v int) KeyValue

                  Int creates a KeyValue instance with either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

                  If creating both key and an int value at the same time, then instead of calling kv.Key(name).Int(value) consider using a convenience function provided by the api/key package - key.Int(name, value).

                  func (Key) Int32

                  func (k Key) Int32(v int32) KeyValue

                    Int32 creates a KeyValue instance with an INT32 Value.

                    If creating both key and an int32 value at the same time, then instead of calling kv.Key(name).Int32(value) consider using a convenience function provided by the api/key package - key.Int32(name, value).

                    func (Key) Int64

                    func (k Key) Int64(v int64) KeyValue

                      Int64 creates a KeyValue instance with an INT64 Value.

                      If creating both key and an int64 value at the same time, then instead of calling kv.Key(name).Int64(value) consider using a convenience function provided by the api/key package - key.Int64(name, value).

                      func (Key) String

                      func (k Key) String(v string) KeyValue

                        String creates a KeyValue instance with a STRING Value.

                        If creating both key and a string value at the same time, then instead of calling kv.Key(name).String(value) consider using a convenience function provided by the api/key package - key.String(name, value).

                        func (Key) Uint

                        func (k Key) Uint(v uint) KeyValue

                          Uint creates a KeyValue instance with either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

                          If creating both key and a uint value at the same time, then instead of calling kv.Key(name).Uint(value) consider using a convenience function provided by the api/key package - key.Uint(name, value).

                          func (Key) Uint32

                          func (k Key) Uint32(v uint32) KeyValue

                            Uint32 creates a KeyValue instance with a UINT32 Value.

                            If creating both key and a uint32 value at the same time, then instead of calling kv.Key(name).Uint32(value) consider using a convenience function provided by the api/key package - key.Uint32(name, value).

                            func (Key) Uint64

                            func (k Key) Uint64(v uint64) KeyValue

                              Uint64 creates a KeyValue instance with a UINT64 Value.

                              If creating both key and a uint64 value at the same time, then instead of calling kv.Key(name).Uint64(value) consider using a convenience function provided by the api/key package - key.Uint64(name, value).

                              type KeyValue

                              type KeyValue struct {
                              	Key   Key
                              	Value Value
                              }

                                KeyValue holds a key and value pair.

                                func Any

                                func Any(k string, value interface{}) KeyValue

                                  Any creates a new key-value pair instance with a passed name and automatic type inference. This is slower, and not type-safe.

                                  func Array

                                  func Array(k string, v interface{}) KeyValue

                                    Array creates a new key-value pair with a passed name and a array. Only arrays of primitive type are supported.

                                    func Bool

                                    func Bool(k string, v bool) KeyValue

                                      Bool creates a new key-value pair with a passed name and a bool value.

                                      func Float32

                                      func Float32(k string, v float32) KeyValue

                                        Float32 creates a new key-value pair with a passed name and a float32 value.

                                        func Float64

                                        func Float64(k string, v float64) KeyValue

                                          Float64 creates a new key-value pair with a passed name and a float64 value.

                                          func Int

                                          func Int(k string, v int) KeyValue

                                            Int creates a new key-value pair instance with a passed name and either an int32 or an int64 value, depending on whether the int type is 32 or 64 bits wide.

                                            func Int32

                                            func Int32(k string, v int32) KeyValue

                                              Int32 creates a new key-value pair with a passed name and an int32 value.

                                              func Int64

                                              func Int64(k string, v int64) KeyValue

                                                Int64 creates a new key-value pair with a passed name and an int64 value.

                                                func String

                                                func String(k, v string) KeyValue

                                                  String creates a new key-value pair with a passed name and a string value.

                                                  func Stringer

                                                  func Stringer(k string, v fmt.Stringer) KeyValue

                                                    Stringer creates a new key-value pair with a passed name and a string value generated by the passed Stringer interface.

                                                    func Uint

                                                    func Uint(k string, v uint) KeyValue

                                                      Uint creates a new key-value pair instance with a passed name and either an uint32 or an uint64 value, depending on whether the uint type is 32 or 64 bits wide.

                                                      func Uint32

                                                      func Uint32(k string, v uint32) KeyValue

                                                        Uint32 creates a new key-value pair with a passed name and a uint32 value.

                                                        func Uint64

                                                        func Uint64(k string, v uint64) KeyValue

                                                          Uint64 creates a new key-value pair with a passed name and a uint64 value.

                                                          type Type

                                                          type Type int

                                                            Type describes the type of the data Value holds.

                                                            const (
                                                            	INVALID Type = iota // No value.
                                                            	BOOL                // Boolean value, use AsBool() to get it.
                                                            	INT32               // 32 bit signed integral value, use AsInt32() to get it.
                                                            	INT64               // 64 bit signed integral value, use AsInt64() to get it.
                                                            	UINT32              // 32 bit unsigned integral value, use AsUint32() to get it.
                                                            	UINT64              // 64 bit unsigned integral value, use AsUint64() to get it.
                                                            	FLOAT32             // 32 bit floating point value, use AsFloat32() to get it.
                                                            	FLOAT64             // 64 bit floating point value, use AsFloat64() to get it.
                                                            	STRING              // String value, use AsString() to get it.
                                                            	ARRAY               // Array value of arbitrary type, use AsArray() to get it.
                                                            )

                                                            func (Type) String

                                                            func (i Type) String() string

                                                            type Value

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

                                                              Value represents the value part in key-value pairs.

                                                              func ArrayValue

                                                              func ArrayValue(array interface{}) Value

                                                                Array creates an ARRAY value.

                                                                func BoolValue

                                                                func BoolValue(v bool) Value

                                                                  BoolValue creates a BOOL Value.

                                                                  func Float32Value

                                                                  func Float32Value(v float32) Value

                                                                    Float32 creates a FLOAT32 Value.

                                                                    func Float64Value

                                                                    func Float64Value(v float64) Value

                                                                      Float64Value creates a FLOAT64 Value.

                                                                      func Int32Value

                                                                      func Int32Value(v int32) Value

                                                                        Int32Value creates an INT32 Value.

                                                                        func Int64Value

                                                                        func Int64Value(v int64) Value

                                                                          Int64Value creates an INT64 Value.

                                                                          func IntValue

                                                                          func IntValue(v int) Value

                                                                            Int creates either an INT32 or an INT64 Value, depending on whether the int type is 32 or 64 bits wide.

                                                                            func StringValue

                                                                            func StringValue(v string) Value

                                                                              String creates a STRING Value.

                                                                              func Uint32Value

                                                                              func Uint32Value(v uint32) Value

                                                                                Uint32 creates a UINT32 Value.

                                                                                func Uint64Value

                                                                                func Uint64Value(v uint64) Value

                                                                                  Uint64Value creates a UINT64 Value.

                                                                                  func UintValue

                                                                                  func UintValue(v uint) Value

                                                                                    Uint creates either a UINT32 or a UINT64 Value, depending on whether the uint type is 32 or 64 bits wide.

                                                                                    func (Value) AsArray

                                                                                    func (v Value) AsArray() interface{}

                                                                                      AsArray returns the array Value as an interface{}.

                                                                                      func (Value) AsBool

                                                                                      func (v Value) AsBool() bool

                                                                                        AsBool returns the bool value. Make sure that the Value's type is BOOL.

                                                                                        func (Value) AsFloat32

                                                                                        func (v Value) AsFloat32() float32

                                                                                          AsFloat32 returns the float32 value. Make sure that the Value's type is FLOAT32.

                                                                                          func (Value) AsFloat64

                                                                                          func (v Value) AsFloat64() float64

                                                                                            AsFloat64 returns the float64 value. Make sure that the Value's type is FLOAT64.

                                                                                            func (Value) AsInt32

                                                                                            func (v Value) AsInt32() int32

                                                                                              AsInt32 returns the int32 value. Make sure that the Value's type is INT32.

                                                                                              func (Value) AsInt64

                                                                                              func (v Value) AsInt64() int64

                                                                                                AsInt64 returns the int64 value. Make sure that the Value's type is INT64.

                                                                                                func (Value) AsInterface

                                                                                                func (v Value) AsInterface() interface{}

                                                                                                  AsInterface returns Value's data as interface{}.

                                                                                                  func (Value) AsString

                                                                                                  func (v Value) AsString() string

                                                                                                    AsString returns the string value. Make sure that the Value's type is STRING.

                                                                                                    func (Value) AsUint32

                                                                                                    func (v Value) AsUint32() uint32

                                                                                                      AsUint32 returns the uint32 value. Make sure that the Value's type is UINT32.

                                                                                                      func (Value) AsUint64

                                                                                                      func (v Value) AsUint64() uint64

                                                                                                        AsUint64 returns the uint64 value. Make sure that the Value's type is UINT64.

                                                                                                        func (Value) Emit

                                                                                                        func (v Value) Emit() string

                                                                                                          Emit returns a string representation of Value's data.

                                                                                                          func (Value) MarshalJSON

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

                                                                                                            MarshalJSON returns the JSON encoding of the Value.

                                                                                                            func (Value) Type

                                                                                                            func (v Value) Type() Type

                                                                                                              Type returns a type of the Value.