Interface returns the Value proto as an interface{}.
(v *structpb.Value, opts ...Option)
| 101 | |
| 102 | // Interface returns the Value proto as an interface{}. |
| 103 | func Interface(v *structpb.Value, opts ...Option) (any, error) { |
| 104 | switch v := v.GetKind().(type) { |
| 105 | case *structpb.Value_NullValue: |
| 106 | return nil, nil |
| 107 | case *structpb.Value_NumberValue: |
| 108 | return v.NumberValue, nil |
| 109 | case *structpb.Value_StringValue: |
| 110 | return v.StringValue, nil |
| 111 | case *structpb.Value_BoolValue: |
| 112 | return v.BoolValue, nil |
| 113 | case *structpb.Value_StructValue: |
| 114 | return Map(v.StructValue, opts...) |
| 115 | case *structpb.Value_ListValue: |
| 116 | return Slice(v.ListValue, opts...) |
| 117 | default: |
| 118 | return nil, fmt.Errorf("unmatched structpb type: %T", v) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | // Struct returns the map as a Struct proto. |
| 123 | func Struct(m map[string]any, opts ...Option) (*structpb.Struct, error) { |