You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In many situations you want to be able to support multiple versions of schemas at the same time so that your customers don't all need to update their applications and services every time you bump a version. But if you are deserialising into strongly-typed, version-specific structs it's difficult to have efficient code that deals with all the common fields across versions because the different versions are different go types.
Since go "polymorphism" uses interfaces (i.e. methods and not properties) one way to deal with multiple versions would be to define interfaces that consist of getters/setters for all the fields, so that the different versioned structs can at least be accessed through lowest-common-denominator interface definitions e.g. everything implements the v1.0 interface, all versions including and above v1.1 support any new fields added in v1.1 etc.
You could probably do this using reflection at runtime, or maybe something with generics, but it seems like it would be less work all round to do it while generating the code, since you already have the field and struct definitions.
The text was updated successfully, but these errors were encountered:
In many situations you want to be able to support multiple versions of schemas at the same time so that your customers don't all need to update their applications and services every time you bump a version. But if you are deserialising into strongly-typed, version-specific structs it's difficult to have efficient code that deals with all the common fields across versions because the different versions are different go types.
Since go "polymorphism" uses interfaces (i.e. methods and not properties) one way to deal with multiple versions would be to define interfaces that consist of getters/setters for all the fields, so that the different versioned structs can at least be accessed through lowest-common-denominator interface definitions e.g. everything implements the v1.0 interface, all versions including and above v1.1 support any new fields added in v1.1 etc.
You could probably do this using reflection at runtime, or maybe something with generics, but it seems like it would be less work all round to do it while generating the code, since you already have the field and struct definitions.
The text was updated successfully, but these errors were encountered: