Value constructs a RawMessage for field number f from v.
(v any)
| 107 | |
| 108 | // Value constructs a RawMessage for field number f from v. |
| 109 | func (f FieldNumber) Value(v any) RawMessage { |
| 110 | switch x := v.(type) { |
| 111 | case bool: |
| 112 | return f.Bool(x) |
| 113 | case int: |
| 114 | return f.Int(x) |
| 115 | case int32: |
| 116 | return f.Int32(x) |
| 117 | case int64: |
| 118 | return f.Int64(x) |
| 119 | case uint: |
| 120 | return f.Uint(x) |
| 121 | case uint32: |
| 122 | return f.Uint32(x) |
| 123 | case uint64: |
| 124 | return f.Uint64(x) |
| 125 | case float32: |
| 126 | return f.Float32(x) |
| 127 | case float64: |
| 128 | return f.Float64(x) |
| 129 | case string: |
| 130 | return f.String(x) |
| 131 | case []byte: |
| 132 | return f.Bytes(x) |
| 133 | default: |
| 134 | panic("cannot rewrite value of unsupported type") |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // The WireType enumeration represents the different protobuf wire types. |
| 139 | type WireType uint |