-
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
Expose DictObject
#1458
Comments
That would be a breaking change. We can't do that. Also, note that even if we did, Objects wouldn't necessarily behave the way we want it to.
This functionality is more conveniently possible with a separate function that takes a non-type-parameterized version:
I can't think of a good name for that function that stands apart from the other such helpers. |
oh, will |
That would, but (I think) that you'd have to always specify the type constraint for that case. It would not be inferred. edit: finishing up that thought: |
I think "VariadicObjects" doesn't match the naming conventions we've been going for. |
Cool, agreed on both points. I'm wondering if
in my own utility library or something, it doesn't need access to internals like |
The reason Objects needs the type parameter is this case: type Item struct{ ... }
func (Item) MarshalLogObject(...) { ... } items := []Item{a, b, c}
zap.Objects("foo", items)
// This:
// func Objects[T zapcore.ObjectMarshaler](name string, items []T) Field
// Becomes:
// func Objects(name string, items []Item) Field It allows the
Then we would not be able to pass
|
ah, I think I see, passing variadic arguments individually just sugars that last slice copy. thanks for taking me into and back out of the generic / slice invariance rabbithole :) |
|
I would like to expose the ObjectMarshaler here: https://github.com/uber-go/zap/blob/v1.27.0/field.go#L425 like this:
so that field functions can be used to construct arbitrary object marshalers, to use with other functions like
Objects
:and this would be especially nice if the signature of
Objects
were changed to use a vararg:The text was updated successfully, but these errors were encountered: