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 support for Stringers field type #598

Closed
JeanMertz opened this issue Jun 7, 2018 · 3 comments
Closed

Add support for Stringers field type #598

JeanMertz opened this issue Jun 7, 2018 · 3 comments

Comments

@JeanMertz
Copy link
Contributor

Zap has support for Stringer, which indeed makes the log entries a bit more simple to construct. However, the real power to me would be if it also had a Stringers (plural) function.

Right now, if you have an array of objects that implement fmt.Stringer, you have to manually loop them, extract the strings, and then call zap.Strings. It would be a lot cleaner if we could simply pass them as-is to Stringers and let Zap handle the rest.

@akshayjshah
Copy link
Contributor

What would the signature of zap.Stringers be? If I have a type *Foo that implements io.Stringer, you can't pass []*Foo as []io.Stringer - you have to allocate a new slice and copy over each element.

@saurabh95
Copy link
Contributor

With generics, this is possible to implement now.
The PR to add this functionality is already merged and released in the latest version: #1155

@abhinav
Copy link
Collaborator

abhinav commented Aug 25, 2022

Yep! Done with #1155. Thanks, @saurabh95.

@abhinav abhinav closed this as completed Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants