Closed jpicht closed 1 year ago
Argh. I'll move them back again. Give me a day or two.
In practice, Value.GetType()
is not really needed or idiomatic in Go, since you could simply type assert on the interface itself like:
v, ok := record.Bins["bin_name"].(int);
if !ok {
// return some error or set v to a default value
}
or you could:
switch record.Bins["bin_name"].(type) {
case int:
///
case float64:
////
}
That does not excuse the issue though. I'll return the type so it works as it did before.
Yeah, I would have done that refactoring if ParticleType.INTEGER
was a one to one mapping, but sadly it's used by multiple types. So it's more work than I can justify right now. We'll tackle the refactoring to idomatic use when we move to the newer versions.
Version v4.7.0 released.
That's great, though that version is unusable, because of #411
Addressed for the #411 in v4.7.1
release.
Solved by v4.7.1, thanks!
Due to massive dependency trees in a lot of old projects we've been stuck on old (ancient) library versions forever. I'm trying to get to the latest v4 version at least, as the massive API changes between v4 and v6 seem insurmountable right now. While upgrading I found a lot of things quite straight forward, but one thing seems broken in the latest v4:
The type consts were hidden (without explanation and without a migration guide) by commit c753dc2, but
Value.GetType()
still returns them. This is very inconsistent and forced me to use an ugly workaround:Is there any better option, that does not require refactoring to not use
GetType
? What is the expected use case forGetType
if the value is intentionally opaque to the library user?