MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Struct

Function Struct

pkg/goproto/struct.go:123–139  ·  view source on GitHub ↗

Struct returns the map as a Struct proto.

(m map[string]any, opts ...Option)

Source from the content-addressed store, hash-verified

121
122// Struct returns the map as a Struct proto.
123func Struct(m map[string]any, opts ...Option) (*structpb.Struct, error) {
124 state, err := createSerializationState(opts...)
125 if err != nil {
126 return nil, err
127 }
128 p := &structpb.Struct{
129 Fields: make(map[string]*structpb.Value),
130 }
131 for k, v := range m {
132 pv, err := Value(v, state.Recurse())
133 if err != nil {
134 return nil, err
135 }
136 p.Fields[k] = pv
137 }
138 return p, nil
139}
140
141// List returns the slice as a ListValue proto.
142func List(s []any, opts ...Option) (*structpb.ListValue, error) {

Callers 14

decodeUplinkMethod · 0.92
decodeDownlinkMethod · 0.92
DecodeUplinkMethod · 0.92
DecodeDownlinkMethod · 0.92
TestStackOverflowFunction · 0.92
ErrorDetailsToProtoFunction · 0.92
mustStructFunction · 0.92
getDecoderMethod · 0.92
GetDownlinkEncoderMethod · 0.92
parseFunction · 0.92
parseFunction · 0.92
TestStructProtoFunction · 0.92

Calls 3

createSerializationStateFunction · 0.85
ValueFunction · 0.85
RecurseMethod · 0.80

Tested by 4

TestStackOverflowFunction · 0.74
mustStructFunction · 0.74
TestStructProtoFunction · 0.74
TestRecursiveStructuresFunction · 0.74