Struct returns the map as a Struct proto.
(m map[string]any, opts ...Option)
| 121 | |
| 122 | // Struct returns the map as a Struct proto. |
| 123 | func 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. |
| 142 | func List(s []any, opts ...Option) (*structpb.ListValue, error) { |