diff --git a/.golangci.yml b/.golangci.yml index 33841f429..89ed6e89c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,10 @@ linters-settings: govet: check-shadowing: true + disable: + # printf: non-constant format string in call to fmt.Errorf (govet) + # showing up since golangci-lint version 1.60.1 + - printf # enable: # - fieldalignment FIXME: golint: diff --git a/serialize.go b/serialize.go index 58c1a5ebf..a43254c75 100644 --- a/serialize.go +++ b/serialize.go @@ -20,7 +20,7 @@ var opts = oj.Options{ KeyExact: true, NestEmbed: false, BytesAs: ojg.BytesAsString, - TimeFormat: time.RFC3339Nano, + TimeFormat: "time", WriteLimit: 1024, } @@ -31,11 +31,12 @@ func Serialize(in map[string]any) (map[string]any, error) { return nil, nil } - // cel supports time.Time and time.Duration natively - save original and then replace it after decomposition + // cel supports time.Duration natively - save original and then replace it after decomposition + // FIXME: This does not work for anything inside Structs nativeTypes := make(map[string]any, len(in)) jp.Walk(in, func(path jp.Expr, value any) { switch v := value.(type) { - case time.Duration, time.Time: + case time.Duration: nativeTypes[path.String()] = v } }) @@ -47,11 +48,9 @@ func Serialize(in map[string]any) (map[string]any, error) { if err != nil { return nil, err } - if err := expr.SetOne(out, v); err != nil { return nil, err } } - return out, nil } diff --git a/structtemplater_test.go b/structtemplater_test.go index eb2ef21f4..34eb1fe9e 100644 --- a/structtemplater_test.go +++ b/structtemplater_test.go @@ -222,7 +222,7 @@ func TestStructTemplater(t *testing.T) { if err := test.StructTemplater.Walk(i); err != nil { t.Error(err) } else if diff := cmp.Diff(i, test.Output); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/tests/cel_test.go b/tests/cel_test.go index e4dcc6ae2..1fab06503 100644 --- a/tests/cel_test.go +++ b/tests/cel_test.go @@ -136,7 +136,7 @@ func TestCelData(t *testing.T) { Address: &Address{City: "Kathmandu"}, } runTests(t, []Test{ - {map[string]interface{}{"i": newFolderCheck(1)}, "i.files[0].modified", testDate}, + {map[string]interface{}{"i": newFolderCheck(1)}, "i.files[0].modified", testDateTime.String()}, {map[string]interface{}{"i": person}, "YAML(toYAML(i)).name", "Aditya"}, // csv {nil, `CSV(["Alice,30", "Bob,31"])[0][0]`, "Alice"}, diff --git a/tests/serialize_test.go b/tests/serialize_test.go index faba9d4e9..b9f3f1ef0 100644 --- a/tests/serialize_test.go +++ b/tests/serialize_test.go @@ -87,12 +87,12 @@ func Test_serialize(t *testing.T) { "name": "test", "size": int64(10), "mode": "drwxr-xr-x", - "modified": testDate, + "modified": testDateTime, }, }, "newest": map[string]any{ "mode": "drwxr-xr-x", - "modified": testDate, + "modified": testDateTime, "name": "test", "size": int64(10), },