Documentation ¶
Overview ¶
Package live provides some types and functions designed for plugin hot reload, which solves the problem that the same type in different versions of a plugin are actually not the same at runtime.
Example ¶
type questInfo1 struct { ID int64 Name string Done bool } q1 := questInfo1{ ID: 5848, Name: "Of Love and Family", } liveObj := MustWrapObject(&q1) // 2000 years later... type questInfo2 struct { ID int64 Name string Desc string Done bool } var q2 questInfo2 q2.Desc = "<>" liveObj.MustUnwrapObject(&q2) fmt.Printf("ID: %v\n", q2.ID) fmt.Printf("Name: %v\n", q2.Name) fmt.Printf("Desc: %v\n", q2.Desc) fmt.Printf("Done: %v\n", q2.Done)
Output: ID: 5848 Name: Of Love and Family Desc: <> Done: false
Index ¶
- type Config
- type Data
- func FromProtorBytes(dAtA []byte) (Data, error)
- func MustWrapObject(obj interface{}) Data
- func MustWrapProtobufObject(obj ProtobufMarshaler) Data
- func WrapBool(v bool) Data
- func WrapBytes(v []byte) Data
- func WrapComplex128(v complex128) Data
- func WrapComplex64(v complex64) Data
- func WrapFloat32(v float32) Data
- func WrapFloat64(v float64) Data
- func WrapInt(v int) Data
- func WrapInt16(v int16) Data
- func WrapInt32(v int32) Data
- func WrapInt64(v int64) Data
- func WrapInt8(v int8) Data
- func WrapObject(obj interface{}) (Data, error)
- func WrapProtobufObject(obj ProtobufMarshaler) (Data, error)
- func WrapString(v string) Data
- func WrapUint(v uint) Data
- func WrapUint16(v uint16) Data
- func WrapUint32(v uint32) Data
- func WrapUint64(v uint64) Data
- func WrapUint8(v uint8) Data
- func WrapValueDirect(v interface{}, cfg Config) Data
- func (d Data) Bool() bool
- func (d Data) Bytes() []byte
- func (d Data) Complex128() complex128
- func (d Data) Complex64() complex64
- func (d Data) Float32() float32
- func (d Data) Float64() float64
- func (d Data) Int() int
- func (d Data) Int16() int16
- func (d Data) Int32() int32
- func (d Data) Int64() int64
- func (d Data) Int8() int8
- func (d Data) MarshalEasyJSON(w *jwriter.Writer)
- func (d Data) MarshalJSON() ([]byte, error)
- func (d Data) Marshallable() bool
- func (d Data) MustUnwrapObject(out interface{})
- func (d Data) MustUnwrapProtobufObject(out ProtobufUnmarshaler)
- func (d Data) String() string
- func (d Data) Uint() uint
- func (d Data) Uint16() uint16
- func (d Data) Uint32() uint32
- func (d Data) Uint64() uint64
- func (d Data) Uint8() uint8
- func (d *Data) UnmarshalEasyJSON(l *jlexer.Lexer)
- func (d *Data) UnmarshalJSON(dAtA []byte) error
- func (d Data) UnwrapObject(out interface{}) error
- func (d Data) UnwrapProtobufObject(out ProtobufUnmarshaler) error
- func (d Data) Value() interface{}
- type ProtobufMarshaler
- type ProtobufUnmarshaler
- type Protor
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Blacklist blacklist SkipTypeCheck bool }
Config has a blacklist, with which it prevents any object of a type defined in a plugin from being converted to a live data by WrapValueDirect. Config also checks whether an object refers to, directly or indirectly, an unsupported type. The unsupported types are: func, uintptr, interface{}, any, and unsafe.Pointer. It panics if any of these types is found.
To force a struct field to bypass the check, give it the following tag: `live:"true"`.
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data is a handy general-purpose data wrapper.
var (
Nil Data
)
func FromProtorBytes ¶
func MustWrapObject ¶
func MustWrapObject(obj interface{}) Data
func MustWrapProtobufObject ¶
func MustWrapProtobufObject(obj ProtobufMarshaler) Data
func WrapComplex128 ¶
func WrapComplex128(v complex128) Data
func WrapComplex64 ¶
func WrapFloat32 ¶
func WrapFloat64 ¶
func WrapObject ¶
func WrapProtobufObject ¶
func WrapProtobufObject(obj ProtobufMarshaler) (Data, error)
func WrapString ¶
func WrapUint16 ¶
func WrapUint32 ¶
func WrapUint64 ¶
func WrapValueDirect ¶
WrapValueDirect converts almost anything into a live data, which is not marshallable.
func (Data) Complex128 ¶
func (d Data) Complex128() complex128
func (Data) MarshalEasyJSON ¶
func (Data) MarshalJSON ¶
func (Data) Marshallable ¶
func (Data) MustUnwrapObject ¶
func (d Data) MustUnwrapObject(out interface{})
func (Data) MustUnwrapProtobufObject ¶
func (d Data) MustUnwrapProtobufObject(out ProtobufUnmarshaler)
func (*Data) UnmarshalEasyJSON ¶
func (*Data) UnmarshalJSON ¶
func (Data) UnwrapObject ¶
func (Data) UnwrapProtobufObject ¶
func (d Data) UnwrapProtobufObject(out ProtobufUnmarshaler) error