Open dirodriguezm opened 4 months ago
On further investigation I found that the problem is not when reading, but when writing. The writeMap
function is writing 0
and also setting the original data as 0
. What should be the correct behavior with this function ?
https://github.com/astrogo/fitsio/blob/f7769148dd4e12bc994ff06944e90f27a13d507c/table.go#L395-L423
On line 415 val
is set as a reflect.New
value which is 0
for numeric types. Then on line 420 the original data map is modified with this new 0
value which I don't understand.
Hi, I found that when writing and reading binary tables from a map, the recovered data is always zero value. For example strings are empty "" and numeric values are 0.
This can be easily replicated with the
TestTableMapsRW
intable_test.go
. Even though the test passes, the values that are scanned to the map do not match with the original data.I'm still a beginner at Go, but I think that calling
reflect.Value.Interface
returns the default value of the interface, so that's why it reads numeric values as 0 and strings as empty strings.