wkt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package wkt -- descriptors.go builds all Well-Known Type descriptors and registers them into the global registries. The init()-based registration is in init_gc.go; TinyGo consumers should call Register() from register.go.

Package wkt implements the protobuf well-known types as defined in the google/protobuf package. It provides Go implementations of Timestamp, Duration, Any, Struct, Value, ListValue, FieldMask, Empty, NullValue, and the nine wrapper types (DoubleValue, FloatValue, Int64Value, UInt64Value, Int32Value, UInt32Value, BoolValue, StringValue, BytesValue).

All types use pre-built descriptors registered into the global type and file registries at package init time. Each message type satisfies the proto.Message interface with correct binary encoding, validation, and standard Go type conversions.

Import path: github.com/0verkilll/protobuf/wkt

Index

Constants

This section is empty.

Variables

Exported descriptor accessors for each WKT type. These enable downstream packages to reference WKT descriptors without registry lookups.

View Source
var EmptyInstance = &Empty{}

EmptyInstance is a package-level singleton for the Empty message. Callers that need a shared immutable Empty can reference this value instead of allocating a new one.

Functions

func Register

func Register()

Register builds all WKT descriptors, constructs file descriptors, registers them into the global registries, and assigns the exported descriptor accessor variables. Under standard Go this is handled by init(); under TinyGo consumers must call Register() explicitly before using WKT descriptors.

Types

type Any

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

Any wraps an arbitrary protobuf message along with a URL that describes the type of the serialized message. It corresponds to google.protobuf.Any.

func NewAny

func NewAny(typeURL string, value []byte) *Any

NewAny creates an Any with the given typeURL and a defensive copy of value.

func (*Any) Clone

func (a *Any) Clone() proto.Message

Clone returns a deep copy of this Any. The value bytes are defensively copied.

func (*Any) Is

func (a *Any) Is(msg proto.Message) bool

Is reports whether the Any's typeURL matches the fully qualified name of msg's descriptor.

func (*Any) Marshal

func (a *Any) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Any.

func (*Any) MarshalAppend

func (a *Any) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Any to b and returns the extended slice. Zero-value fields are omitted per proto3 semantics.

func (*Any) Merge

func (a *Any) Merge(src proto.Message) error

Merge merges the fields of src into this Any. The src must be an *Any; otherwise Merge returns a type mismatch error. The typeURL is overwritten and value bytes are defensively copied.

func (*Any) PackFrom

func (a *Any) PackFrom(msg proto.Message) error

PackFrom serializes msg and stores the result in the Any, setting the typeURL to "type.googleapis.com/" followed by the message's fully qualified name obtained from its descriptor.

func (*Any) ProtoReflect

func (a *Any) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Any's fields via the pre-built Any descriptor.

func (*Any) Reset

func (a *Any) Reset()

Reset clears the Any to its zero state.

func (*Any) Size

func (a *Any) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. Zero-value fields are omitted per proto3 semantics.

func (*Any) TypeName

func (a *Any) TypeName() string

TypeName extracts the fully qualified message name from the typeURL by returning everything after the last "/" character. It returns an empty string if the typeURL is empty or contains no "/".

func (*Any) TypeURL

func (a *Any) TypeURL() string

TypeURL returns the type URL string.

func (*Any) Unmarshal

func (a *Any) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Any. Field 1 is decoded as the typeURL string, field 2 as the value bytes.

func (*Any) UnpackTo

func (a *Any) UnpackTo(msg proto.Message) error

UnpackTo deserializes the Any's value into msg. It returns an error if the typeURL does not match the message's fully qualified name.

func (*Any) Validate

func (a *Any) Validate() error

Validate checks that the Any satisfies structural constraints. A non-empty value requires a non-empty typeURL.

func (*Any) Value

func (a *Any) Value() []byte

Value returns a defensive copy of the serialized message bytes.

type BoolValue

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

BoolValue wraps a bool value, corresponding to google.protobuf.BoolValue.

func NewBoolValue

func NewBoolValue(v bool) *BoolValue

NewBoolValue creates a BoolValue wrapping v.

func (*BoolValue) Clone

func (w *BoolValue) Clone() proto.Message

Clone returns a deep copy of the BoolValue.

func (*BoolValue) Marshal

func (w *BoolValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the BoolValue.

func (*BoolValue) MarshalAppend

func (w *BoolValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the BoolValue to b and returns the extended slice. A false value is omitted per proto3 semantics.

func (*BoolValue) Merge

func (w *BoolValue) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *BoolValue; otherwise Merge returns a type mismatch error.

func (*BoolValue) ProtoReflect

func (w *BoolValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*BoolValue) Reset

func (w *BoolValue) Reset()

Reset clears the BoolValue to its zero state.

func (*BoolValue) Size

func (w *BoolValue) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A false value produces a zero size per proto3 semantics.

func (*BoolValue) Unmarshal

func (w *BoolValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the BoolValue. Field 1 is decoded as a bool; unknown fields are skipped.

func (*BoolValue) Validate

func (w *BoolValue) Validate() error

Validate checks structural constraints. BoolValue has no constraints beyond its type, so Validate always returns nil.

func (*BoolValue) Value

func (w *BoolValue) Value() bool

Value returns the wrapped bool.

type BoolValueKind

type BoolValueKind struct{ Value bool }

BoolValueKind wraps a bool for the bool_value oneof variant (field 4).

type BytesValue

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

BytesValue wraps a bytes ([]byte) value, corresponding to google.protobuf.BytesValue.

func NewBytesValue

func NewBytesValue(v []byte) *BytesValue

NewBytesValue creates a BytesValue wrapping a defensive copy of v.

func (*BytesValue) Clone

func (w *BytesValue) Clone() proto.Message

Clone returns a deep copy of the BytesValue. The value bytes are defensively copied.

func (*BytesValue) Marshal

func (w *BytesValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the BytesValue.

func (*BytesValue) MarshalAppend

func (w *BytesValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the BytesValue to b and returns the extended slice. An empty or nil slice is omitted per proto3 semantics.

func (*BytesValue) Merge

func (w *BytesValue) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *BytesValue; otherwise Merge returns a type mismatch error. The value bytes are defensively copied.

func (*BytesValue) ProtoReflect

func (w *BytesValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*BytesValue) Reset

func (w *BytesValue) Reset()

Reset clears the BytesValue to its zero state.

func (*BytesValue) Size

func (w *BytesValue) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. An empty or nil slice produces a zero size per proto3 semantics.

func (*BytesValue) Unmarshal

func (w *BytesValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the BytesValue. Field 1 is decoded as a byte slice; unknown fields are skipped. The decoded bytes are defensively copied.

func (*BytesValue) Validate

func (w *BytesValue) Validate() error

Validate checks structural constraints. BytesValue has no constraints beyond its type, so Validate always returns nil.

func (*BytesValue) Value

func (w *BytesValue) Value() []byte

Value returns a defensive copy of the wrapped bytes.

type DoubleValue

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

DoubleValue wraps a double (float64) value, corresponding to google.protobuf.DoubleValue.

func NewDoubleValue

func NewDoubleValue(v float64) *DoubleValue

NewDoubleValue creates a DoubleValue wrapping v.

func (*DoubleValue) Clone

func (w *DoubleValue) Clone() proto.Message

Clone returns a deep copy of the DoubleValue.

func (*DoubleValue) Marshal

func (w *DoubleValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the DoubleValue.

func (*DoubleValue) MarshalAppend

func (w *DoubleValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the DoubleValue to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*DoubleValue) Merge

func (w *DoubleValue) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *DoubleValue; otherwise Merge returns a type mismatch error.

func (*DoubleValue) ProtoReflect

func (w *DoubleValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*DoubleValue) Reset

func (w *DoubleValue) Reset()

Reset clears the DoubleValue to its zero state.

func (*DoubleValue) Size

func (w *DoubleValue) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*DoubleValue) Unmarshal

func (w *DoubleValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the DoubleValue. Field 1 is decoded as a double; unknown fields are skipped.

func (*DoubleValue) Validate

func (w *DoubleValue) Validate() error

Validate checks structural constraints. DoubleValue has no constraints beyond its type, so Validate always returns nil.

func (*DoubleValue) Value

func (w *DoubleValue) Value() float64

Value returns the wrapped double.

type Duration

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

Duration represents the google.protobuf.Duration well-known type. It holds a signed duration as seconds and nanoseconds, where nanos must have the same sign as seconds (or be zero).

func NewDuration

func NewDuration(d time.Duration) *Duration

NewDuration creates a Duration from a Go time.Duration value by decomposing it into seconds and the nanosecond remainder.

func (*Duration) AsDuration

func (d *Duration) AsDuration() time.Duration

AsDuration converts the Duration to a Go time.Duration value. If the value exceeds the representable range of time.Duration, it clamps to math.MinInt64 or math.MaxInt64 nanoseconds.

func (*Duration) Clone

func (d *Duration) Clone() proto.Message

Clone returns a deep copy of the Duration.

func (*Duration) Marshal

func (d *Duration) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Duration.

func (*Duration) MarshalAppend

func (d *Duration) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Duration to b and returns the extended slice. Zero-valued fields are omitted per proto3.

func (*Duration) Merge

func (d *Duration) Merge(src proto.Message) error

Merge merges the fields of src into this Duration. The src must be a *Duration. Non-zero fields from src overwrite the corresponding fields in the receiver.

func (*Duration) Nanos

func (d *Duration) Nanos() int32

Nanos returns the nanoseconds component of the duration.

func (*Duration) ProtoReflect

func (d *Duration) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Duration's fields via the pre-built Duration descriptor.

func (*Duration) Reset

func (d *Duration) Reset()

Reset zeros both fields, returning the Duration to its initial state.

func (*Duration) Seconds

func (d *Duration) Seconds() int64

Seconds returns the seconds component of the duration.

func (*Duration) Size

func (d *Duration) Size() int

Size returns the exact number of bytes the serialized Duration will occupy. Zero-valued fields are omitted per proto3 semantics.

func (*Duration) Unmarshal

func (d *Duration) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Duration. It uses the decoder's DecodeMessage with a field handler dispatching on field numbers 1 (seconds) and 2 (nanos).

func (*Duration) Validate

func (d *Duration) Validate() error

Validate checks that the Duration fields are within the valid protobuf range. Seconds must be in [-315576000000, 315576000000]. Nanos must be in [-999999999, 999999999]. Nanos must have the same sign as seconds or be zero.

type Empty

type Empty struct{}

Empty represents the google.protobuf.Empty well-known type. It contains no fields and produces zero bytes when serialized.

func (*Empty) Clone

func (e *Empty) Clone() proto.Message

Clone returns a new independent copy of the Empty message.

func (*Empty) Marshal

func (e *Empty) Marshal() ([]byte, error)

Marshal returns the serialized form of the Empty message. Because Empty has no fields, it returns nil.

func (*Empty) MarshalAppend

func (e *Empty) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the serialized form of the Empty message to b and returns the unchanged slice. Because Empty has no fields, no bytes are appended.

func (*Empty) Merge

func (e *Empty) Merge(src proto.Message) error

Merge merges src into the receiver. The src must be an *Empty; otherwise Merge returns a type mismatch error. Because Empty has no fields, Merge is a no-op.

func (*Empty) ProtoReflect

func (e *Empty) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Empty message via the pre-built Empty descriptor.

func (*Empty) Reset

func (e *Empty) Reset()

Reset returns the Empty message to its zero state. Because Empty has no fields, Reset is a no-op.

func (*Empty) Size

func (e *Empty) Size() int

Size returns the serialized size of the Empty message, which is always 0.

func (*Empty) Unmarshal

func (e *Empty) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Empty message. All fields are treated as unknown and silently skipped.

func (*Empty) Validate

func (e *Empty) Validate() error

Validate checks the Empty message for schema violations. Empty has no constraints and always returns nil.

type FieldMask

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

FieldMask represents the google.protobuf.FieldMask well-known type. It contains a set of dot-separated field paths that identify which fields of a message should be read or written.

func NewFieldMask

func NewFieldMask(paths ...string) *FieldMask

NewFieldMask creates a new FieldMask with the given paths. The input variadic slice is defensively copied.

func (*FieldMask) Clone

func (fm *FieldMask) Clone() proto.Message

Clone returns a new independent deep copy of the FieldMask.

func (*FieldMask) Intersect

func (fm *FieldMask) Intersect(other *FieldMask) *FieldMask

Intersect returns a new FieldMask containing only paths present in both this mask and other.

func (*FieldMask) IsValid

IsValid checks whether every path in the field mask is a valid field path for the given message descriptor. Each dot-separated segment is walked against the descriptor tree. A path is invalid if any segment does not correspond to a known field, or if a non-terminal segment refers to a non-message field.

func (*FieldMask) Marshal

func (fm *FieldMask) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the FieldMask.

func (*FieldMask) MarshalAppend

func (fm *FieldMask) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the FieldMask to b and returns the extended slice. Each path is encoded as a repeated string field at field number 1.

func (*FieldMask) Merge

func (fm *FieldMask) Merge(src proto.Message) error

Merge merges src into the receiver by appending src's paths. The src must be a *FieldMask; otherwise Merge returns a type mismatch error.

func (*FieldMask) Normalize

func (fm *FieldMask) Normalize() *FieldMask

Normalize returns a new FieldMask with paths deduplicated, sorted lexicographically, and with sub-paths removed. A sub-path is a path that is a strict prefix of another path when split on dots. For example, if both "a.b" and "a.b.c" are present, "a.b.c" is removed because "a.b" already covers it.

func (*FieldMask) Paths

func (fm *FieldMask) Paths() []string

Paths returns a defensive copy of the field mask's paths.

func (*FieldMask) ProtoReflect

func (fm *FieldMask) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the FieldMask's fields via the pre-built FieldMask descriptor.

func (*FieldMask) Reset

func (fm *FieldMask) Reset()

Reset clears the FieldMask to its zero state.

func (*FieldMask) Size

func (fm *FieldMask) Size() int

Size returns the exact number of bytes the serialized FieldMask would occupy. Each path is encoded as a repeated string at field number 1.

func (*FieldMask) Union

func (fm *FieldMask) Union(other *FieldMask) *FieldMask

Union returns a new FieldMask containing the set union of paths from both this mask and other. The result is normalized.

func (*FieldMask) Unmarshal

func (fm *FieldMask) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the FieldMask. It collects all field 1 strings into the paths slice. Unknown fields are silently skipped.

func (*FieldMask) Validate

func (fm *FieldMask) Validate() error

Validate checks that the FieldMask satisfies structural constraints. It returns an error if any path is an empty string.

type FloatValue

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

FloatValue wraps a float (float32) value, corresponding to google.protobuf.FloatValue.

func NewFloatValue

func NewFloatValue(v float32) *FloatValue

NewFloatValue creates a FloatValue wrapping v.

func (*FloatValue) Clone

func (w *FloatValue) Clone() proto.Message

Clone returns a deep copy of the FloatValue.

func (*FloatValue) Marshal

func (w *FloatValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the FloatValue.

func (*FloatValue) MarshalAppend

func (w *FloatValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the FloatValue to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*FloatValue) Merge

func (w *FloatValue) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *FloatValue; otherwise Merge returns a type mismatch error.

func (*FloatValue) ProtoReflect

func (w *FloatValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*FloatValue) Reset

func (w *FloatValue) Reset()

Reset clears the FloatValue to its zero state.

func (*FloatValue) Size

func (w *FloatValue) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*FloatValue) Unmarshal

func (w *FloatValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the FloatValue. Field 1 is decoded as a float; unknown fields are skipped.

func (*FloatValue) Validate

func (w *FloatValue) Validate() error

Validate checks structural constraints. FloatValue has no constraints beyond its type, so Validate always returns nil.

func (*FloatValue) Value

func (w *FloatValue) Value() float32

Value returns the wrapped float.

type Int32Value

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

Int32Value wraps an int32 value, corresponding to google.protobuf.Int32Value.

func NewInt32Value

func NewInt32Value(v int32) *Int32Value

NewInt32Value creates an Int32Value wrapping v.

func (*Int32Value) Clone

func (w *Int32Value) Clone() proto.Message

Clone returns a deep copy of the Int32Value.

func (*Int32Value) Marshal

func (w *Int32Value) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Int32Value.

func (*Int32Value) MarshalAppend

func (w *Int32Value) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Int32Value to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*Int32Value) Merge

func (w *Int32Value) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *Int32Value; otherwise Merge returns a type mismatch error.

func (*Int32Value) ProtoReflect

func (w *Int32Value) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*Int32Value) Reset

func (w *Int32Value) Reset()

Reset clears the Int32Value to its zero state.

func (*Int32Value) Size

func (w *Int32Value) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*Int32Value) Unmarshal

func (w *Int32Value) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Int32Value. Field 1 is decoded as an int32; unknown fields are skipped.

func (*Int32Value) Validate

func (w *Int32Value) Validate() error

Validate checks structural constraints. Int32Value has no constraints beyond its type, so Validate always returns nil.

func (*Int32Value) Value

func (w *Int32Value) Value() int32

Value returns the wrapped int32.

type Int64Value

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

Int64Value wraps an int64 value, corresponding to google.protobuf.Int64Value.

func NewInt64Value

func NewInt64Value(v int64) *Int64Value

NewInt64Value creates an Int64Value wrapping v.

func (*Int64Value) Clone

func (w *Int64Value) Clone() proto.Message

Clone returns a deep copy of the Int64Value.

func (*Int64Value) Marshal

func (w *Int64Value) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Int64Value.

func (*Int64Value) MarshalAppend

func (w *Int64Value) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Int64Value to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*Int64Value) Merge

func (w *Int64Value) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *Int64Value; otherwise Merge returns a type mismatch error.

func (*Int64Value) ProtoReflect

func (w *Int64Value) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*Int64Value) Reset

func (w *Int64Value) Reset()

Reset clears the Int64Value to its zero state.

func (*Int64Value) Size

func (w *Int64Value) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*Int64Value) Unmarshal

func (w *Int64Value) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Int64Value. Field 1 is decoded as an int64; unknown fields are skipped.

func (*Int64Value) Validate

func (w *Int64Value) Validate() error

Validate checks structural constraints. Int64Value has no constraints beyond its type, so Validate always returns nil.

func (*Int64Value) Value

func (w *Int64Value) Value() int64

Value returns the wrapped int64.

type ListValue

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

ListValue represents the google.protobuf.ListValue well-known type. It holds an ordered list of dynamically typed Value elements, analogous to a JSON array.

func NewListValue

func NewListValue(values []*Value) *ListValue

NewListValue creates a ListValue with a defensive copy of the given values slice.

func (*ListValue) Clone

func (lv *ListValue) Clone() proto.Message

Clone returns a deep copy of the ListValue.

func (*ListValue) Marshal

func (lv *ListValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the ListValue.

func (*ListValue) MarshalAppend

func (lv *ListValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the ListValue to b and returns the extended slice. Each value is encoded as a repeated message field at field number 1.

func (*ListValue) Merge

func (lv *ListValue) Merge(src proto.Message) error

Merge merges src into the receiver by appending deep copies of src's values. The src must be a *ListValue.

func (*ListValue) ProtoReflect

func (lv *ListValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the ListValue's fields via the pre-built ListValue descriptor.

func (*ListValue) Reset

func (lv *ListValue) Reset()

Reset clears the ListValue to its zero state.

func (*ListValue) Size

func (lv *ListValue) Size() int

Size returns the exact number of bytes the serialized ListValue will occupy. Each value is encoded as a repeated message at field number 1.

func (*ListValue) Unmarshal

func (lv *ListValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the ListValue. Each field 1 entry is decoded as a Value message and appended to the values slice.

func (*ListValue) Validate

func (lv *ListValue) Validate() error

Validate checks the ListValue for structural violations. ListValue has no constraints and always returns nil.

func (*ListValue) Values

func (lv *ListValue) Values() []*Value

Values returns a defensive copy of the list's values slice.

type ListValueKind

type ListValueKind struct{ Value *ListValue }

ListValueKind wraps a *ListValue for the list_value oneof variant (field 6).

type NullValue

type NullValue int32

NullValue represents the google.protobuf.NullValue enum, which is used to represent a JSON null in the protobuf type system. It has a single defined value of 0 (NULL_VALUE).

const NullValue_NULL_VALUE NullValue = 0

NullValue_NULL_VALUE is the sole defined value of the NullValue enum, representing JSON null.

func (NullValue) Number

func (n NullValue) Number() int32

Number returns the enum numeric value as int32.

func (NullValue) String

func (n NullValue) String() string

String returns the protobuf name of the enum value.

type NullValueKind

type NullValueKind struct{ Value NullValue }

NullValueKind wraps a NullValue for the null_value oneof variant (field 1).

type NumberValueKind

type NumberValueKind struct{ Value float64 }

NumberValueKind wraps a float64 for the number_value oneof variant (field 2).

type StringValue

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

StringValue wraps a string value, corresponding to google.protobuf.StringValue.

func NewStringValue

func NewStringValue(v string) *StringValue

NewStringValue creates a StringValue wrapping v.

func (*StringValue) Clone

func (w *StringValue) Clone() proto.Message

Clone returns a deep copy of the StringValue.

func (*StringValue) Marshal

func (w *StringValue) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the StringValue.

func (*StringValue) MarshalAppend

func (w *StringValue) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the StringValue to b and returns the extended slice. An empty string is omitted per proto3 semantics.

func (*StringValue) Merge

func (w *StringValue) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *StringValue; otherwise Merge returns a type mismatch error.

func (*StringValue) ProtoReflect

func (w *StringValue) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*StringValue) Reset

func (w *StringValue) Reset()

Reset clears the StringValue to its zero state.

func (*StringValue) Size

func (w *StringValue) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. An empty string produces a zero size per proto3 semantics.

func (*StringValue) Unmarshal

func (w *StringValue) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the StringValue. Field 1 is decoded as a string; unknown fields are skipped.

func (*StringValue) Validate

func (w *StringValue) Validate() error

Validate checks structural constraints. StringValue has no constraints beyond its type, so Validate always returns nil.

func (*StringValue) Value

func (w *StringValue) Value() string

Value returns the wrapped string.

type StringValueKind

type StringValueKind struct{ Value string }

StringValueKind wraps a string for the string_value oneof variant (field 3).

type Struct

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

Struct represents the google.protobuf.Struct well-known type. It holds a set of named fields, each containing a dynamically typed Value, analogous to a JSON object.

func NewStruct

func NewStruct(fields map[string]*Value) *Struct

NewStruct creates a Struct with a defensive copy of the given fields map.

func NewStructFromMap

func NewStructFromMap(m map[string]any) (*Struct, error)

NewStructFromMap creates a Struct from a map[string]any by converting each value to a *Value using anyToValue. Supported value types are nil, bool, float64, int, int64, string, []any, and map[string]any. Unsupported types produce an error. This method is the marshal-direction counterpart to AsMap.

func (*Struct) AsMap

func (s *Struct) AsMap() map[string]any

AsMap converts the Struct to a map[string]any by recursively converting each *Value to its Go native equivalent. This is the unmarshal-direction counterpart to NewStructFromMap.

func (*Struct) Clone

func (s *Struct) Clone() proto.Message

Clone returns a deep copy of the Struct.

func (*Struct) Fields

func (s *Struct) Fields() map[string]*Value

Fields returns a defensive copy of the struct's field map.

func (*Struct) Marshal

func (s *Struct) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Struct.

func (*Struct) MarshalAppend

func (s *Struct) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Struct to b and returns the extended slice. Each map entry is encoded as a length-delimited sub-message at outer field 1, containing the key at inner field 1 (string) and the value at inner field 2 (message).

func (*Struct) Merge

func (s *Struct) Merge(src proto.Message) error

Merge merges src into the receiver. The src must be a *Struct. For each key in src, if the receiver already has that key the values are merged recursively; otherwise the entry is inserted as a deep copy.

func (*Struct) ProtoReflect

func (s *Struct) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Struct's fields via the pre-built Struct descriptor.

func (*Struct) Reset

func (s *Struct) Reset()

Reset clears the Struct to its zero state.

func (*Struct) Size

func (s *Struct) Size() int

Size returns the exact number of bytes the serialized Struct will occupy. Each map entry is encoded as a length-delimited sub-message at field 1.

func (*Struct) Unmarshal

func (s *Struct) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Struct. Each field 1 entry is decoded as a map entry sub-message containing a string key (inner field 1) and a Value message (inner field 2).

func (*Struct) Validate

func (s *Struct) Validate() error

Validate checks the Struct for structural violations. Struct has no constraints and always returns nil.

type StructValueKind

type StructValueKind struct{ Value *Struct }

StructValueKind wraps a *Struct for the struct_value oneof variant (field 5).

type Timestamp

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

Timestamp represents the google.protobuf.Timestamp well-known type. It holds a point in time as seconds and nanoseconds since the Unix epoch (1970-01-01 UTC).

func NewTimestamp

func NewTimestamp(t time.Time) *Timestamp

NewTimestamp creates a Timestamp from a Go time.Time value by extracting the Unix seconds and nanosecond remainder.

func (*Timestamp) AsTime

func (t *Timestamp) AsTime() time.Time

AsTime converts the Timestamp to a Go time.Time value in UTC.

func (*Timestamp) Clone

func (t *Timestamp) Clone() proto.Message

Clone returns a deep copy of the Timestamp.

func (*Timestamp) Marshal

func (t *Timestamp) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Timestamp.

func (*Timestamp) MarshalAppend

func (t *Timestamp) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Timestamp to b and returns the extended slice. Zero-valued fields are omitted per proto3.

func (*Timestamp) Merge

func (t *Timestamp) Merge(src proto.Message) error

Merge merges the fields of src into this Timestamp. The src must be a *Timestamp. Non-zero fields from src overwrite the corresponding fields in the receiver.

func (*Timestamp) Nanos

func (t *Timestamp) Nanos() int32

Nanos returns the nanoseconds component of the timestamp.

func (*Timestamp) ProtoReflect

func (t *Timestamp) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Timestamp's fields via the pre-built Timestamp descriptor.

func (*Timestamp) Reset

func (t *Timestamp) Reset()

Reset zeros both fields, returning the Timestamp to its initial state.

func (*Timestamp) Seconds

func (t *Timestamp) Seconds() int64

Seconds returns the seconds component of the timestamp.

func (*Timestamp) Size

func (t *Timestamp) Size() int

Size returns the exact number of bytes the serialized Timestamp will occupy. Zero-valued fields are omitted per proto3 semantics.

func (*Timestamp) Unmarshal

func (t *Timestamp) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Timestamp. It uses the decoder's DecodeMessage with a field handler dispatching on field numbers 1 (seconds) and 2 (nanos).

func (*Timestamp) Validate

func (t *Timestamp) Validate() error

Validate checks that the Timestamp fields are within the valid protobuf range. Seconds must be in [-62135596800, 253402300799] (0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). Nanos must be in [0, 999999999].

type UInt32Value

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

UInt32Value wraps a uint32 value, corresponding to google.protobuf.UInt32Value.

func NewUInt32Value

func NewUInt32Value(v uint32) *UInt32Value

NewUInt32Value creates a UInt32Value wrapping v.

func (*UInt32Value) Clone

func (w *UInt32Value) Clone() proto.Message

Clone returns a deep copy of the UInt32Value.

func (*UInt32Value) Marshal

func (w *UInt32Value) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the UInt32Value.

func (*UInt32Value) MarshalAppend

func (w *UInt32Value) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the UInt32Value to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*UInt32Value) Merge

func (w *UInt32Value) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *UInt32Value; otherwise Merge returns a type mismatch error.

func (*UInt32Value) ProtoReflect

func (w *UInt32Value) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*UInt32Value) Reset

func (w *UInt32Value) Reset()

Reset clears the UInt32Value to its zero state.

func (*UInt32Value) Size

func (w *UInt32Value) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*UInt32Value) Unmarshal

func (w *UInt32Value) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the UInt32Value. Field 1 is decoded as a uint32; unknown fields are skipped.

func (*UInt32Value) Validate

func (w *UInt32Value) Validate() error

Validate checks structural constraints. UInt32Value has no constraints beyond its type, so Validate always returns nil.

func (*UInt32Value) Value

func (w *UInt32Value) Value() uint32

Value returns the wrapped uint32.

type UInt64Value

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

UInt64Value wraps a uint64 value, corresponding to google.protobuf.UInt64Value.

func NewUInt64Value

func NewUInt64Value(v uint64) *UInt64Value

NewUInt64Value creates a UInt64Value wrapping v.

func (*UInt64Value) Clone

func (w *UInt64Value) Clone() proto.Message

Clone returns a deep copy of the UInt64Value.

func (*UInt64Value) Marshal

func (w *UInt64Value) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the UInt64Value.

func (*UInt64Value) MarshalAppend

func (w *UInt64Value) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the UInt64Value to b and returns the extended slice. A zero value is omitted per proto3 semantics.

func (*UInt64Value) Merge

func (w *UInt64Value) Merge(src proto.Message) error

Merge copies the value from src into the receiver. The src must be a *UInt64Value; otherwise Merge returns a type mismatch error.

func (*UInt64Value) ProtoReflect

func (w *UInt64Value) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access.

func (*UInt64Value) Reset

func (w *UInt64Value) Reset()

Reset clears the UInt64Value to its zero state.

func (*UInt64Value) Size

func (w *UInt64Value) Size() int

Size returns the exact number of bytes the wire-format encoding will occupy. A zero value produces a zero size per proto3 semantics.

func (*UInt64Value) Unmarshal

func (w *UInt64Value) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the UInt64Value. Field 1 is decoded as a uint64; unknown fields are skipped.

func (*UInt64Value) Validate

func (w *UInt64Value) Validate() error

Validate checks structural constraints. UInt64Value has no constraints beyond its type, so Validate always returns nil.

func (*UInt64Value) Value

func (w *UInt64Value) Value() uint64

Value returns the wrapped uint64.

type Value

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

Value represents the google.protobuf.Value well-known type. It holds a dynamically typed value via a sealed oneof interface with six variants: null, number, string, bool, struct, and list.

func ValueOfBool

func ValueOfBool(v bool) *Value

ValueOfBool creates a Value with the bool_value variant.

func ValueOfList

func ValueOfList(v *ListValue) *Value

ValueOfList creates a Value with the list_value variant.

func ValueOfNull

func ValueOfNull() *Value

ValueOfNull creates a Value with the null_value variant.

func ValueOfNumber

func ValueOfNumber(v float64) *Value

ValueOfNumber creates a Value with the number_value variant.

func ValueOfString

func ValueOfString(v string) *Value

ValueOfString creates a Value with the string_value variant.

func ValueOfStruct

func ValueOfStruct(v *Struct) *Value

ValueOfStruct creates a Value with the struct_value variant.

func (*Value) Clone

func (v *Value) Clone() proto.Message

Clone returns a deep copy of the Value.

func (*Value) GetBoolValue

func (v *Value) GetBoolValue() bool

GetBoolValue returns the bool if the active variant is BoolValueKind, or false otherwise.

func (*Value) GetKind

func (v *Value) GetKind() valueKind

GetKind returns the active oneof variant, or nil if no variant is set.

func (*Value) GetListValue

func (v *Value) GetListValue() *ListValue

GetListValue returns the list if the active variant is ListValueKind, or nil otherwise.

func (*Value) GetNullValue

func (v *Value) GetNullValue() NullValue

GetNullValue returns the null value if the active variant is NullValueKind, or the zero NullValue otherwise.

func (*Value) GetNumberValue

func (v *Value) GetNumberValue() float64

GetNumberValue returns the number if the active variant is NumberValueKind, or 0 otherwise.

func (*Value) GetStringValue

func (v *Value) GetStringValue() string

GetStringValue returns the string if the active variant is StringValueKind, or "" otherwise.

func (*Value) GetStructValue

func (v *Value) GetStructValue() *Struct

GetStructValue returns the struct if the active variant is StructValueKind, or nil otherwise.

func (*Value) Marshal

func (v *Value) Marshal() ([]byte, error)

Marshal returns the wire-format encoding of the Value.

func (*Value) MarshalAppend

func (v *Value) MarshalAppend(b []byte) ([]byte, error)

MarshalAppend appends the wire-format encoding of the Value to b and returns the extended slice. Only the active oneof field is encoded.

func (*Value) Merge

func (v *Value) Merge(src proto.Message) error

Merge merges the fields of src into this Value. The src must be a *Value. The kind from src overwrites the kind in the receiver, with deep copies for struct and list variants.

func (*Value) ProtoReflect

func (v *Value) ProtoReflect() protoreflect.Message

ProtoReflect returns a protoreflect.Message providing dynamic field access to the Value's oneof fields via the pre-built Value descriptor.

func (*Value) Reset

func (v *Value) Reset()

Reset clears the Value, setting kind to nil.

func (*Value) Size

func (v *Value) Size() int

Size returns the exact number of bytes the serialized Value will occupy.

func (*Value) Unmarshal

func (v *Value) Unmarshal(b []byte) error

Unmarshal decodes wire-format bytes into the Value. For the oneof, the last field encountered wins.

func (*Value) Validate

func (v *Value) Validate() error

Validate checks that the Value has an active oneof variant set.

Jump to

Keyboard shortcuts

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