decoder: handle casting local date into time.Time

Refs #494
This commit is contained in:
Thomas Pelletier
2021-04-08 08:00:31 -04:00
parent 18af62d3ea
commit 275e366c17
3 changed files with 33 additions and 0 deletions
+15
View File
@@ -4,6 +4,7 @@ import (
"math"
"strconv"
"testing"
"time"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"
@@ -780,6 +781,20 @@ val1 = "test1"
require.Equal(t, "test2", cfg.Val2)
}
func TestIssue494(t *testing.T) {
data := `
foo = 2021-04-08
bar = 2021-04-08
`
type s struct {
Foo time.Time `toml:"foo"`
Bar time.Time `toml:"bar"`
}
ss := new(s)
err := toml.Unmarshal([]byte(data), ss)
require.NoError(t, err)
}
func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {
desc string