first commit
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
andrey1s
2021-04-26 16:07:41 +03:00
commit d6e6001d6b
18 changed files with 348 additions and 0 deletions

22
toml/encoding.go Normal file
View File

@@ -0,0 +1,22 @@
package toml
import (
"io"
"github.com/BurntSushi/toml"
"gitoa.ru/go-4devs/encoding"
)
var _ encoding.Decode = Decode
var _ encoding.Encode = Encode
// Decode from reader to value.
func Decode(r io.Reader, v interface{}) error {
_, err := toml.DecodeReader(r, v)
return err
}
// Encode from value to writer.
func Encode(w io.Writer, v interface{}) error {
return toml.NewEncoder(w).Encode(v)
}

19
toml/encoding_test.go Normal file
View File

@@ -0,0 +1,19 @@
package toml_test
import (
"testing"
"gitoa.ru/go-4devs/encoding/test"
"gitoa.ru/go-4devs/encoding/toml"
)
const data = `
string = "string data"
time = 2020-05-24T09:15:00Z
[struct]
id = 42
`
func TestDecode(t *testing.T) {
test.RunDecode(t, toml.Decode, data)
}