-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add func DictObject
#1460
Add func DictObject
#1460
Conversation
Thanks for the PR, @MayCXC. |
you got it, I added doc comments & tests. |
field.go
Outdated
// DictObject exposes the [zapcore.ObjectMarshaler] for an array of [Field] to | ||
// use with functions like [Object] and [Objects]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would reword this a bit. Object/Objects aren't the only uses of this.
// DictObject exposes the [zapcore.ObjectMarshaler] for an array of [Field] to | |
// use with functions like [Object] and [Objects]. | |
// DictObject constructs a [zapcore.ObjectMarshaler] with the given list of fields. | |
// The resulting object may be used as input to [Object], [Objects], | |
// or anywhere else that an object is expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworded it a bit based on this feedback
b: zap.Object("k", zap.DictObject(zap.String("a", "b"))), | ||
want: true, | ||
}, | ||
{ | ||
a: zap.Object("k", zap.DictObject(zap.String("a", "b"))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example test is good, and this equality check makes sense.
Would you also mind adding a test similar to TestDict that asserts the shape of the resulting JSON-ey object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
…yCXC/add-dictobject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Will wait for an Uber maintainer to also stamp before merging.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1460 +/- ##
=======================================
Coverage 98.70% 98.70%
=======================================
Files 53 53
Lines 3018 3020 +2
=======================================
+ Hits 2979 2981 +2
Misses 31 31
Partials 8 8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good to me. Thanks for the PR @MayCXC !
Allows fields to be used to construct
ObjectMarshaler
s that can then be used with other functions likefunc Objects
. Link to issue: #1458