Closed ibrt closed 8 years ago
Thanks for this!
If I'm reading it correctly, this change assumes that any []byte
field will be base64 (specifically with StdEncoding
). That seems like a higher-level assumption than we should be making here.
Rather than building this into envconfig itself, it might be a great use-case for a custom decoder from #35 (I can merge that now -- it's sat for a while waiting feedback) roughly like this:
type b64 []byte
func (b *b64) Decode(value string) error {
bytes, err := base64.StdEncoding.DecodeString(value)
if err != nil {
return err
}
*b = bytes
return nil
}
var conf = struct {
EncryptionKey b64
}{}
func init() {
envconfig.MustProcess("prefix", &conf)
}
The use case I have for this is encryption keys.