Documentation ¶
Overview ¶
Package reg provide a key-value data storage.
the storage is actually a JSON tree
keys are strings, can be separate into multiple level, like the path of filesystem. the separator is '/', leading and ending '/' is ignored, continious '/' is treat as single '/', so "/foo//bar/" is same as "foo/bar". keys are case sensitive.
internal values should be valid JSON type, i.e. one of nil, bool, float64, string, []interface{} or map[string]interface{}. but we also provide interfaces for compatible types, plus an universal Marshal method. when putting non-standard values into storage, they are converted to JSON types.
Index ¶
- Variables
- type Reg
- func (rg *Reg) Encode() ([]byte, error)
- func (rg *Reg) EncodeIndent(prefix, indent string) ([]byte, error)
- func (rg *Reg) GetBool(key string) (x bool, err error)
- func (rg *Reg) GetBytes(key string) (x []byte, err error)
- func (rg *Reg) GetFloat32(key string) (x float32, err error)
- func (rg *Reg) GetFloat64(key string) (x float64, err error)
- func (rg *Reg) GetInt(key string) (x int, err error)
- func (rg *Reg) GetInt32(key string) (x int32, err error)
- func (rg *Reg) GetInt64(key string) (x int64, err error)
- func (rg *Reg) GetString(key string) (x string, err error)
- func (rg *Reg) GetUint(key string) (x uint, err error)
- func (rg *Reg) GetUint32(key string) (x uint32, err error)
- func (rg *Reg) GetUint64(key string) (x uint64, err error)
- func (rg *Reg) GetUnmarshal(key string, v interface{}) error
- func (rg *Reg) SetBool(key string, x bool) error
- func (rg *Reg) SetBytes(key string, x []byte) error
- func (rg *Reg) SetFloat32(key string, x float32) error
- func (rg *Reg) SetFloat64(key string, x float64) error
- func (rg *Reg) SetInt(key string, x int) error
- func (rg *Reg) SetInt32(key string, x int32) error
- func (rg *Reg) SetInt64(key string, x int64) error
- func (rg *Reg) SetMarshal(key string, v interface{}) error
- func (rg *Reg) SetString(key string, x string) error
- func (rg *Reg) SetUint(key string, x uint) error
- func (rg *Reg) SetUint32(key string, x float32) error
- func (rg *Reg) SetUint64(key string, x uint64) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Reg ¶
type Reg struct {
// contains filtered or unexported fields
}
Reg is key-value database.
func DecodeReader ¶
DecodeReader decode JSON tree from reader
func (*Reg) EncodeIndent ¶
EncodeIndent like Encode, with indentation
func (*Reg) GetFloat32 ¶
GetFloat32 get float32 value
func (*Reg) GetFloat64 ¶
GetFloat64 get float64 value
func (*Reg) GetUnmarshal ¶
GetUnmarshal use josn.Unmarshal to get data at key
func (*Reg) SetFloat32 ¶
SetFloat32 set float32 value
func (*Reg) SetFloat64 ¶
SetFloat64 set float64 value
func (*Reg) SetMarshal ¶
SetMarshal use josn.Marshal to set data to key