aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/config/config.go3
-rw-r--r--pkg/config/config_test.go9
2 files changed, 12 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index fc77d2496..537b9f3d6 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -99,6 +99,9 @@ func checkUnknownFieldsStruct(val interface{}, prefix string, typ reflect.Type)
if typ.Kind() != reflect.Struct {
return nil
}
+ if typ.PkgPath() == "time" && typ.Name() == "Time" {
+ return nil
+ }
inner, err := json.Marshal(val)
if err != nil {
return fmt.Errorf("failed to marshal inner struct '%v%v':", prefix, err)
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index ee8a79661..6d3ce034e 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -8,6 +8,7 @@ import (
"fmt"
"reflect"
"testing"
+ "time"
)
func TestLoad(t *testing.T) {
@@ -29,6 +30,7 @@ func TestLoad(t *testing.T) {
Box Nested
Boq *Nested
Arr []Nested
+ T time.Time
}
tests := []struct {
@@ -162,6 +164,13 @@ func TestLoad(t *testing.T) {
Config{},
"",
},
+ {
+ `{"t": "2000-01-02T03:04:05Z"}`,
+ Config{
+ T: time.Date(2000, 1, 2, 3, 4, 5, 0, time.UTC),
+ },
+ "",
+ },
}
for i, test := range tests {
t.Run(fmt.Sprint(i), func(t *testing.T) {