Documentation ¶
Overview ¶
Package gogoproto implements conversions from well-known gogo/profobuf types.
Index ¶
- func GoFieldsPaths(pb *pbtypes.FieldMask, v interface{}) []string
- func Interface(v *types.Value) (interface{}, error)
- func List(s []interface{}) (*types.ListValue, error)
- func Map(p *types.Struct) (map[string]interface{}, error)
- func Slice(l *types.ListValue) ([]interface{}, error)
- func Struct(m map[string]interface{}) (*types.Struct, error)
- func Value(v interface{}) (*types.Value, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoFieldsPaths ¶
GoFieldsPaths converts protobuf FieldMask paths to Go fields paths.
This implementation does not support separation by ",", but only paths separated by ".".
Example ¶
package main import ( "fmt" pbtypes "github.com/gogo/protobuf/types" "go.thethings.network/lorawan-stack/pkg/gogoproto" ) func main() { type cityDetails struct { Name string `protobuf:"name=name_city"` } type place struct { NameOfTheRegion string `protobuf:"name=name_region"` CityDetails cityDetails `protobuf:"bytes,name=city"` } london := place{ CityDetails: cityDetails{Name: "London"}, } holland := place{ NameOfTheRegion: "Holland", } fields := gogoproto.GoFieldsPaths(&pbtypes.FieldMask{ Paths: []string{"city.name_city"}, }, london) fmt.Println(fields) fields = gogoproto.GoFieldsPaths(&pbtypes.FieldMask{ Paths: []string{"name_region"}, }, holland) fmt.Println(fields) }
Output: [CityDetails.Name] [NameOfTheRegion]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.