563768b58a
* Move to v3 Co-authored-by: Ben Toogood <bentoogood@gmail.com>
27 lines
436 B
Go
27 lines
436 B
Go
package hcl
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/hashicorp/hcl"
|
|
"github.com/micro/go-micro/v3/config/encoder"
|
|
)
|
|
|
|
type hclEncoder struct{}
|
|
|
|
func (h hclEncoder) Encode(v interface{}) ([]byte, error) {
|
|
return json.Marshal(v)
|
|
}
|
|
|
|
func (h hclEncoder) Decode(d []byte, v interface{}) error {
|
|
return hcl.Unmarshal(d, v)
|
|
}
|
|
|
|
func (h hclEncoder) String() string {
|
|
return "hcl"
|
|
}
|
|
|
|
func NewEncoder() encoder.Encoder {
|
|
return hclEncoder{}
|
|
}
|