viper/internal/encoding/hcl/codec.go

38 lines
727 B
Go
Raw Normal View History

package hcl
import (
"bytes"
)
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for HCL encoding.
// TODO: add printer config to the codec?
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
2022-12-12 16:17:28 +03:00
// b, err := json.Marshal(v)
// if err != nil {
// return nil, err
// }
// TODO: use printer.Format? Is the trailing newline an issue?
2022-12-12 16:17:28 +03:00
// ast, err := hcl.Parse(string(b))
// if err != nil {
// return nil, err
// }
var buf bytes.Buffer
2022-12-12 16:17:28 +03:00
// err = printer.Fprint(&buf, ast.Node)
// if err != nil {
// return nil, err
// }
return buf.Bytes(), nil
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
2022-12-12 16:17:28 +03:00
// return hcl.Unmarshal(b, &v)
return nil
}