Skip to content
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

Merged
merged 6 commits into from
Aug 18, 2024
Merged

Add func DictObject #1460

merged 6 commits into from
Aug 18, 2024

Conversation

MayCXC
Copy link
Contributor

@MayCXC MayCXC commented Aug 15, 2024

Allows fields to be used to construct ObjectMarshalers that can then be used with other functions like func Objects. Link to issue: #1458

@CLAassistant
Copy link

CLAassistant commented Aug 15, 2024

CLA assistant check
All committers have signed the CLA.

@abhinav
Copy link
Collaborator

abhinav commented Aug 16, 2024

Thanks for the PR, @MayCXC.
This change makes sense to me.
Would you mind adding some documentation and tests for this?

@MayCXC MayCXC marked this pull request as draft August 17, 2024 07:57
@MayCXC
Copy link
Contributor Author

MayCXC commented Aug 17, 2024

Thanks for the PR, @MayCXC. This change makes sense to me. Would you mind adding some documentation and tests for this?

you got it, I added doc comments & tests.

@MayCXC MayCXC marked this pull request as ready for review August 17, 2024 09:14
example_test.go Outdated Show resolved Hide resolved
field.go Outdated
Comment on lines 434 to 435
// DictObject exposes the [zapcore.ObjectMarshaler] for an array of [Field] to
// use with functions like [Object] and [Objects].
Copy link
Collaborator

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.

Suggested change
// 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.

Copy link
Contributor Author

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

Comment on lines +325 to +329
b: zap.Object("k", zap.DictObject(zap.String("a", "b"))),
want: true,
},
{
a: zap.Object("k", zap.DictObject(zap.String("a", "b"))),
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MayCXC MayCXC requested a review from abhinav August 17, 2024 20:19
Copy link
Collaborator

@abhinav abhinav left a 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.

CC @sywhang @r-hang @JacobOaks

Copy link

codecov bot commented Aug 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (3f27eb9) to head (9bd3a78).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sywhang sywhang left a 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 !

@sywhang sywhang merged commit 5786471 into uber-go:master Aug 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants