encodeValue encodes a Go value as a Firestore Value. The Firestore proto definition for Value is a oneof of various types, including basic types like string as well as lists and maps.
(x any)
| 48 | // The Firestore proto definition for Value is a oneof of various types, |
| 49 | // including basic types like string as well as lists and maps. |
| 50 | func encodeValue(x any) (*pb.Value, error) { |
| 51 | var e encoder |
| 52 | if err := driver.Encode(reflect.ValueOf(x), &e); err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | return e.pv, nil |
| 56 | } |
| 57 | |
| 58 | // encoder implements driver.Encoder. Its job is to encode a single Firestore value. |
| 59 | type encoder struct { |
no test coverage detected