Description
Expected Behavior
Can use UUID type for storing structs in hash tables
Current Behavior
Got invalid UUID length: 16
error from (uuid *UUID) UnmarshalText
Possible Solution
Add encoding.BinaryUnmarshaler
to switch case at /internal/hscan/structmap.go:107
Steps to Reproduce
- Create structure with UUID field
- Set it to hash table with HSet()
- Get it back with HGetAll()
- Try to write given map[string]string to structure with Scan()
Detailed Description
I am facing a problem related to hash tables. I want to store objects in it, so I use HSet. Then encoding.BinaryMarshaler
is used to marshal the UUID, but when I try to get the object back using Scan(), encoding.TextUnmarshaler
is used instead of encoding.BinaryUnmarshaler
to unmarshal it.
This is a incorrect use of these interfaces. As it is written in the description of these interfaces
UnmarshalBinary must be able to decode the form generated by MarshalBinary
And
UnmarshalText must be able to decode the form generated by MarshalText
They are not interchangeable and Binary should be used with Binary and Text with Text