itkinside/itkconfig

Inferred struct

Closed this issue · 2 comments

I am just starting to use Go (total noob here), so I really don't know if what I am going to suggest is possible.

It would be cool if the struct could be inferred from the configuration file. By that, I mean that the user would not need to declare the struct. This would remove duplication and improve maintainability: if you change the configuration file (add/remove a new configuration) then you would not have to change it in two places.

As I said, I have no clue if that's possible to achieve.

If this is implemented it should be done through an independent command line utility. jsonutils have implemented similar functionality for parsing json data into Go structs.

Since Go is a compiled language, it would not be possible to create the struct automatically from the configuration file at run time.

It is possible to create a tool that creates the necessary struct, as mewmew suggests, but as the structure is fairly simple, I don't really see the need for it.