You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm a student and I'm currently experimenting with ygot in a university project.
Within this scenario I work with a generated GoStruct that also includes read-only fields. For my use case, an option to ignore read-only fields while unmarshalling into a GoStruct (e.g., when preparing a gNMI.SetRequest) would be really useful.
I'm aware of the excludeState option for the generator but since I sometimes need read-only fields (e.g., unmarshalling data from a gnmi.GetResponse) and in some cases I do not, this option does not really fit.
One possible solution could be to extend the ytypes.Unmarshal function which allows to ignore read-only fields while unmarshalling. For example like:
type IgnoreReadOnlyFields struct{}
// IsUnmarshalOpt marks IgnoreReadOnlyFields as a valid UnmarshalOpt.
func (*IgnoreReadOnlyFields) IsUnmarshalOpt() {}
I've tested this in a fork and if this is something that ygot would benefit from, then I would also try to add this to the project.
The text was updated successfully, but these errors were encountered:
There is currently a workaround for the problem you described, which is to call the function ygot.PruneConfigFalse. I will admit this is not very discoverable by autocomplete tools, and is an issue that we should take a look at.
I think using the workaround might be easier from a user perspective (once we have the discoverability issue fixed).
However, if your change is pretty simple it might be worth the maintenance effort. I'd say feel free to open a PR and reference this issue so we can at least keep your work in the record.
Hi,
I'm a student and I'm currently experimenting with ygot in a university project.
Within this scenario I work with a generated
GoStruct
that also includesread-only
fields. For my use case, an option to ignoreread-only
fields while unmarshalling into a GoStruct (e.g., when preparing agNMI.SetRequest
) would be really useful.I'm aware of the
excludeState
option for thegenerator
but since I sometimes needread-only
fields (e.g., unmarshalling data from agnmi.GetResponse
) and in some cases I do not, this option does not really fit.One possible solution could be to extend the ytypes.Unmarshal function which allows to ignore
read-only
fields while unmarshalling. For example like:I've tested this in a fork and if this is something that ygot would benefit from, then I would also try to add this to the project.
The text was updated successfully, but these errors were encountered: