pluginConfig demonstrates how to implement dynamic unmarshaling based on a "type" field. This pattern is useful for plugin systems or polymorphic configuration.
| 100 | // based on a "type" field. This pattern is useful for plugin systems |
| 101 | // or polymorphic configuration. |
| 102 | type pluginConfig struct { |
| 103 | Type string |
| 104 | Config any |
| 105 | } |
| 106 | |
| 107 | func (p *pluginConfig) UnmarshalTOML(data []byte) error { |
| 108 | // First, decode just the type field |
nothing calls this directly
no outgoing calls
no test coverage detected