2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-05 00:00:14 +00:00
cointop/pkg/toml/toml.go

38 lines
728 B
Go
Raw Normal View History

2020-12-21 04:38:49 +00:00
package toml
import (
"io"
"github.com/BurntSushi/toml"
)
// MetaData is meta data struct
type MetaData = toml.MetaData
// Encoder is encoder struct
type Encoder struct {
encoder *toml.Encoder
}
// NewEncoder returns a new encoder instance
func NewEncoder(w io.Writer) *Encoder {
return &Encoder{
encoder: toml.NewEncoder(w),
}
}
// Encode encodes interface to toml
func (enc *Encoder) Encode(v interface{}) error {
return enc.encoder.Encode(v)
}
// Decode decodes toml data to interface
func Decode(data string, v interface{}) (MetaData, error) {
return toml.Decode(data, v)
}
// DecodeFile decodes toml file
func DecodeFile(fpath string, v interface{}) (MetaData, error) {
return toml.DecodeFile(fpath, v)
}