I have to create a JSON from a MS-SQL Database through Go. The problem is that some database fields are created dynamically in backend system (not Go).
There could be:
type Demotable struct{
Id int
Name string
Adress int
Z_somedynamicfield string
Z_anotherfield int
}
All fields prefixed with "Z_" are dynamic, so struct could also be:
type Demotable struct{
Id int
Name string
Adress int
Z_completedifferent int
Z_notlikefirst string
Z_evenmorefields string
}
I also have a helper table where every "dynamic field" is described:
| tableName | fieldName | fieldType |
+-----------+--------------------+-----------+
| Demotable | Z_somedynamicfield | string |
+-----------+--------------------+-----------+
| Demotable | Z_anotherfield | int |
...
Ideally I would dynamically "extend" struct with infos from helper table - but I don't have an idea how or if this even is possible?