-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Description
Hello !
When using funcr
implementation with JSON formatter, produced JSON is invalid when omitting fields using json
struct tag.
How to reproduce
type Foo struct {
Bar string `json:"-"`
Baz string `json:"baz"`
}
func main() {
logger := funcr.NewJSON(
func(obj string) { fmt.Println(obj) },
funcr.Options{},
)
logger.Info("", "foo", Foo{})
}
Expected output
{"logger":"","level":0,"msg":"","foo":{"baz":""}}
Got output
{"logger":"","level":0,"msg":"","foo":{,"baz":""}}
Notice the extra comma before baz
key.
A quick investigation pointed this line as the potential issue.
Thanks for your help !
Metadata
Metadata
Assignees
Labels
No labels