Documentation ¶
Overview ¶
Package protopath defines methods for getting and setting nested proto fields using selectors.
A path is defined as a period-delimited list of Go proto field names, i.e. "Msg.Field.SubField". Repeated fields can be indexed using a numeric field name, i.e. "Msg.RepeatedField.0.SubField". To refer to the last repeat element use the special field name "-1". Setting index "-1" will extend an array, not replace the last element.
Index ¶
Constants ¶
const Zero zeroType = 0
Zero represents the zero value of any type, it can be used in Set as the value argument to set the value at the path to its corresponding zero value, or Get as the default value, to return the zero value of the field being retrieved if the field is valid but not populated.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get retrieves a value from a V2 proto at `path`, or returns a default value. An error will occur if the path is invalid, or the default value's type is incompatible with the type of the field at `path`.
If the last value of `path` is a oneof then the populated field of the oneof will be returned. `defVal` is ignored in this case, an error will be returned if the oneof is not populated.
If the input message is nil, the default value will be returned.
func Set ¶
Set sets the value of a proto at `path`. An error will occur if the path is invalid, or the specified value's type is incompatible with the type of the field at `path`.
If the last value of `path` is a oneof then the field of the oneof that is assignable to value will be set. If multiple fields have the same type an error is returned.
If the input message is nil, an error will be returned.