TypeForValue finds a data type suitable for v. Use [Map.RegisterType] to register types that can encode and decode themselves. Use [Map.RegisterDefaultPgType] to register that can be handled by a registered data type. The returned [Type] must not be mutated.
(v any)
| 328 | // themselves. Use [Map.RegisterDefaultPgType] to register that can be handled by a registered data type. The returned [Type] |
| 329 | // must not be mutated. |
| 330 | func (m *Map) TypeForValue(v any) (*Type, bool) { |
| 331 | if m.reflectTypeToType == nil { |
| 332 | m.buildReflectTypeToType() |
| 333 | } |
| 334 | |
| 335 | if dt, ok := m.reflectTypeToType[reflect.TypeOf(v)]; ok { |
| 336 | return dt, true |
| 337 | } |
| 338 | |
| 339 | dt, ok := defaultMap.reflectTypeToType[reflect.TypeOf(v)] |
| 340 | return dt, ok |
| 341 | } |
| 342 | |
| 343 | // FormatCodeForOID returns the preferred format code for type oid. If the type is not registered it returns the text |
| 344 | // format code. |
no test coverage detected