I have a GoLang API server project in which I currently use iota with a custom type (Method). I created a custom Marshal function to output the details related to Method whenever it is Marshaled for output to an API client. I have now gotten to a point where some of these Methods will be 'enabled' or 'disabled' depending on how the yaml config file for the project is set up by the end-user. I want to add a field in the custom Marshal, called "enabled" that will be true if the particular method is configured as enabled when the server starts.
I suspect what I want to do isn't possible but kind of wanted to run it past people smarter than me before I moved forward. Since I don't think I can add that, my plan is to essentially scrap iota and the separation of the custom iota type Method from the Details struct and make one consolidated struct that is configured on start up and saved in the challenges service for access.
Service config:
https://github.com/gregtwallace/legocerthub-backend/blob/master/pkg/challenges/service.go
The "enabled" field would need to be based off of Service's providers member (map[Method]providerService). If the Method wasn't null in the map, enabled would be true. If the Method was null, enabled would be false.
Method code:
https://github.com/gregtwallace/legocerthub-backend/blob/master/pkg/challenges/method.go
Contains iota and Marshal func.
https://github.com/gregtwallace/legocerthub-backend/blob/master/pkg/challenges/methods.go
Contains details about the Methods.
Note: The code to actually enable or disable Methods hasn't been implemented yet. Right now the two existing methods are both mandatory or the app won't start (errors and exit).