diff --git a/README.md b/README.md index 5e12698..c32ae60 100644 --- a/README.md +++ b/README.md @@ -62,12 +62,12 @@ type UserAddress struct { func (u *User) MarshalLogObject(e zapcore.ObjectEncoder) error { e.AddString("name", u.Name) e.AddInt("age", u.Age) - e.OpenNamespace("address") - e.AddString("street", u.Address.Street) - e.AddString("city", u.Address.City) if u.Friend != nil { _ = e.AddObject("friend", u.Friend) } + e.OpenNamespace("address") + e.AddString("street", u.Address.Street) + e.AddString("city", u.Address.City) return nil } diff --git a/internal/readme/readme.tmpl b/internal/readme/readme.tmpl index 398616c..78c55ee 100644 --- a/internal/readme/readme.tmpl +++ b/internal/readme/readme.tmpl @@ -62,12 +62,12 @@ type UserAddress struct { func (u *User) MarshalLogObject(e zapcore.ObjectEncoder) error { e.AddString("name", u.Name) e.AddInt("age", u.Age) - e.OpenNamespace("address") - e.AddString("street", u.Address.Street) - e.AddString("city", u.Address.City) if u.Friend != nil { _ = e.AddObject("friend", u.Friend) } + e.OpenNamespace("address") + e.AddString("street", u.Address.Street) + e.AddString("city", u.Address.City) return nil }