Documentation
¶
Index ¶
- Variables
- type Dict
- func (x *Dict) AsMap() map[string]interface{}
- func (x *Dict) Clone() *Dict
- func (*Dict) Descriptor() ([]byte, []int)deprecated
- func (x *Dict) Get(key string) *Value
- func (x *Dict) GetFields() map[string]*Value
- func (x *Dict) MarshalJSON() ([]byte, error)
- func (x *Dict) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error)
- func (*Dict) ProtoMessage()
- func (x *Dict) ProtoReflect() protoreflect.Message
- func (x *Dict) Reset()
- func (x *Dict) Set(key string, value *Value) bool
- func (x *Dict) String() string
- func (x *Dict) ToStarlark() *starlark.Dict
- func (x *Dict) UnmarshalJSON(p []byte) error
- func (x *Dict) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
- type List
- func (x *List) AsSlice() []interface{}
- func (x *List) Clone() *List
- func (*List) Descriptor() ([]byte, []int)deprecated
- func (x *List) GetValues() []*Value
- func (x *List) MarshalJSON() ([]byte, error)
- func (x *List) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error)
- func (*List) ProtoMessage()
- func (x *List) ProtoReflect() protoreflect.Message
- func (x *List) Reset()
- func (x *List) String() string
- func (x *List) ToStarlark() *starlark.List
- func (x *List) UnmarshalJSON(p []byte) error
- func (x *List) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
- type NullValue
- func (NullValue) Descriptor() protoreflect.EnumDescriptor
- func (x NullValue) Enum() *NullValue
- func (NullValue) EnumDescriptor() ([]byte, []int)deprecated
- func (x NullValue) Number() protoreflect.EnumNumber
- func (x NullValue) String() string
- func (x *NullValue) ToStarlark() starlark.NoneType
- func (NullValue) Type() protoreflect.EnumType
- type Value
- func (x *Value) AsInterface() interface{}
- func (x *Value) Clone() *Value
- func (*Value) Descriptor() ([]byte, []int)deprecated
- func (x *Value) GetBoolValue() bool
- func (x *Value) GetDictValue() *Dict
- func (x *Value) GetFloatValue() float64
- func (x *Value) GetIntValue() int64
- func (x *Value) GetKind() isValue_Kind
- func (x *Value) GetListValue() *List
- func (x *Value) GetNullValue() NullValue
- func (x *Value) GetStringValue() string
- func (x *Value) MarshalJSON() ([]byte, error)
- func (x *Value) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error)
- func (*Value) ProtoMessage()
- func (x *Value) ProtoReflect() protoreflect.Message
- func (x *Value) Reset()
- func (x *Value) String() string
- func (x *Value) ToStarlark() starlark.Value
- func (x *Value) UnmarshalJSON(p []byte) error
- func (x *Value) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
- func (x *Value) Unwrap() interface{}
- type Value_BoolValue
- type Value_DictValue
- type Value_FloatValue
- type Value_IntValue
- type Value_ListValue
- type Value_NullValue
- type Value_StringValue
Constants ¶
This section is empty.
Variables ¶
var ( NullValue_name = map[int32]string{ 0: "NULL_VALUE", } NullValue_value = map[string]int32{ "NULL_VALUE": 0, } )
Enum value maps for NullValue.
var File_struct_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Dict ¶ added in v0.2.0
type Dict struct { // Unordered map of dynamically typed values. Fields map[string]*Value `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
`Dict` represents a structured data value, consisting of fields which map to dynamically typed values.
The JSON representation for `Struct` is JSON object.
func NewDict ¶ added in v0.2.0
NewDict constructs a Struct from a general-purpose Go map. The map keys must be valid UTF-8. The map values are converted using NewValue.
func NewEmptyDict ¶ added in v0.2.0
func NewEmptyDict() *Dict
func (*Dict) AsMap ¶ added in v0.2.0
AsMap converts x to a general-purpose Go map. The map values are converted by calling Value.AsInterface.
func (*Dict) Descriptor
deprecated
added in
v0.2.0
func (*Dict) MarshalJSON ¶ added in v0.2.0
func (*Dict) MarshalJSONPB ¶ added in v0.2.0
func (*Dict) ProtoMessage ¶ added in v0.2.0
func (*Dict) ProtoMessage()
func (*Dict) ProtoReflect ¶ added in v0.2.0
func (x *Dict) ProtoReflect() protoreflect.Message
func (*Dict) Set ¶ added in v0.2.0
Set equals x.Fields[key] = value but is more safe return value is false only if struct == nil
func (*Dict) ToStarlark ¶ added in v0.2.0
func (*Dict) UnmarshalJSON ¶ added in v0.2.0
func (*Dict) UnmarshalJSONPB ¶ added in v0.2.0
func (x *Dict) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
type List ¶ added in v0.2.0
type List struct { // Repeated field of dynamically typed values. Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` // contains filtered or unexported fields }
`List` is a wrapper around a repeated field of values.
The JSON representation for `List` is JSON array.
func NewEmptyList ¶ added in v0.1.4
func NewEmptyList() *List
func NewList ¶
NewList constructs a ListValue from a general-purpose Go slice. The slice elements are converted using NewValue.
func NewStringList ¶
NewStringList constructs a ListValue from a gstring Go slice. The slice elements are converted using NewValue.
func (*List) AsSlice ¶ added in v0.2.0
func (x *List) AsSlice() []interface{}
AsSlice converts x to a general-purpose Go slice. The slice elements are converted by calling Value.AsInterface.
func (*List) Descriptor
deprecated
added in
v0.2.0
func (*List) MarshalJSON ¶ added in v0.2.0
func (*List) MarshalJSONPB ¶ added in v0.2.0
func (*List) ProtoMessage ¶ added in v0.2.0
func (*List) ProtoMessage()
func (*List) ProtoReflect ¶ added in v0.2.0
func (x *List) ProtoReflect() protoreflect.Message
func (*List) ToStarlark ¶ added in v0.2.0
func (*List) UnmarshalJSON ¶ added in v0.2.0
func (*List) UnmarshalJSONPB ¶ added in v0.2.0
func (x *List) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
type NullValue ¶
type NullValue int32
`NullValue` is a singleton enumeration to represent the null value for the `Value` type union.
The JSON representation for `NullValue` is JSON `null`.
const ( // Null value. NullValue_NULL_VALUE NullValue = 0 )
func (NullValue) Descriptor ¶
func (NullValue) Descriptor() protoreflect.EnumDescriptor
func (NullValue) EnumDescriptor
deprecated
func (NullValue) Number ¶
func (x NullValue) Number() protoreflect.EnumNumber
func (*NullValue) ToStarlark ¶
func (NullValue) Type ¶
func (NullValue) Type() protoreflect.EnumType
type Value ¶
type Value struct { // The kind of value. // // Types that are assignable to Kind: // *Value_NullValue // *Value_IntValue // *Value_FloatValue // *Value_StringValue // *Value_BoolValue // *Value_DictValue // *Value_ListValue Kind isValue_Kind `protobuf_oneof:"kind"` // contains filtered or unexported fields }
`Value` represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. A producer of value is expected to set one of that variants, absence of any variant indicates an error.
The JSON representation for `Value` is JSON value.
func NewFloatValue ¶
NewFloatValue constructs a new float number Value.
func NewIntValue ¶
NewIntValue constructs a new integer number Value.
func NewStringValue ¶
NewStringValue constructs a new string Value.
func NewStructValue ¶
NewStructValue constructs a new struct Value.
func NewValue ¶
NewValue constructs a Value from a general-purpose Go interface.
╔════════════════════════╤════════════════════════════════════════════╗ ║ Go type │ Conversion ║ ╠════════════════════════╪════════════════════════════════════════════╣ ║ nil │ stored as NullValue ║ ║ bool │ stored as BoolValue ║ ║ int, int* │ stored as IntValue ║ ║ uint* │ stored as IntValue ║ ║ uint, uint64 │ stored as IntValue / FloatValue ║ ║ float32, float64 │ stored as FloatValue ║ ║ string │ stored as StringValue; must be valid UTF-8 ║ ║ []byte │ stored as StringValue; base64-encoded ║ ║ map[string]interface{} │ stored as StructValue ║ ║ []interface{} │ stored as ListValue ║ ╚════════════════════════╧════════════════════════════════════════════╝
When converting an int64 or uint64 to a NumberValue, numeric precision loss is possible since they are stored as a float64.
func (*Value) AsInterface ¶
func (x *Value) AsInterface() interface{}
AsInterface converts x to a general-purpose Go interface.
Unlike Unwrap, this function will always return Go's basic types.
For Null, Int, String, Bool, the return value is same as Unwrap (will return nil, int64, string, bool) For Float, this may return a float64 or "NaN" "Infinity" "-Infinity" string For Dict, this will return a map[string]interface{}, which is returned from (*Dict).AsMap() For List, this will return a []interface{}, which is returned from (*List).AsSlice()
Call from nil is safe
func (*Value) Descriptor
deprecated
func (*Value) GetBoolValue ¶
func (*Value) GetDictValue ¶ added in v0.2.0
func (*Value) GetFloatValue ¶
func (*Value) GetIntValue ¶
func (*Value) GetListValue ¶
func (*Value) GetNullValue ¶
func (*Value) GetStringValue ¶
func (*Value) MarshalJSON ¶
func (*Value) ProtoMessage ¶
func (*Value) ProtoMessage()
func (*Value) ProtoReflect ¶
func (x *Value) ProtoReflect() protoreflect.Message
func (*Value) ToStarlark ¶
func (*Value) UnmarshalJSON ¶ added in v0.1.4
func (*Value) UnmarshalJSONPB ¶ added in v0.1.4
func (x *Value) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, p []byte) error
type Value_BoolValue ¶
type Value_BoolValue struct { // Represents a boolean value. BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` }
type Value_DictValue ¶ added in v0.2.0
type Value_DictValue struct { // Represents a structured value. DictValue *Dict `protobuf:"bytes,5,opt,name=dict_value,json=dictValue,proto3,oneof"` }
type Value_FloatValue ¶
type Value_FloatValue struct { // Represents a float value. FloatValue float64 `protobuf:"fixed64,2,opt,name=float_value,json=floatValue,proto3,oneof"` }
type Value_IntValue ¶
type Value_IntValue struct { // Represents a number value IntValue int64 `protobuf:"varint,7,opt,name=int_value,json=intValue,proto3,oneof"` }
type Value_ListValue ¶
type Value_ListValue struct { // Represents a repeated `Value`. ListValue *List `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"` }
type Value_NullValue ¶
type Value_NullValue struct { // Represents a null value. NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=struct.NullValue,oneof"` }
type Value_StringValue ¶
type Value_StringValue struct { // Represents a string value. StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` }