I have a third party client library (Sarama) that exposes a configuration struct.
I want to reference that struct directly from my configuration struct:
type MyConfig struct {
Sarama sarama.Config
}
I am using go-yaml to marshal my configuration. Marshalling MyConfig
with go-yaml panics because sarama.Config
contains a field (Partitioner
) that is of type func
and the yaml parser doesn't know how to Marshal
a func
.
A way of preventing this panic would be to tell go-yaml to ignore this field (using the tag yaml:"-"
on the field) but I am unable to set tags on a struct that isn't defined in my code.
Is there an elegant go way to include this configuration in my own configuration and not cause the go-yaml marshaller to panic? Should I try and override the tag or should I copy the struct into my own code and write a converter?