-
Notifications
You must be signed in to change notification settings - Fork 590
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
Decode into pointer fields in-place. #38
Labels
v1
Relates to the v1 line of releases
Comments
ianremmler
added a commit
to ianremmler/hcl
that referenced
this issue
Sep 25, 2015
If decoding into a pointer, and the pointer points to a value, decode into the exitsing value. Otherwise, decode into a new value and point to it. Addresses issue hashicorp#38.
ianremmler
added a commit
to ianremmler/hcl
that referenced
this issue
Sep 25, 2015
If decoding into a pointer, and the pointer points to a value, decode into the exitsing value. Otherwise, decode into a new value and point to it. Addresses issue hashicorp#38.
langmartin
pushed a commit
that referenced
this issue
Apr 25, 2019
If decoding into a pointer, and the pointer points to a value, decode into the exitsing value. Otherwise, decode into a new value and point to it. Addresses issue #38.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be nice if decodePtr() would operate on the thing being pointed to rather than decoding into a new concrete value and assigning its address to the pointer.
I've found this behaviour handy using encoding/json, for example. Say I have a struct prepopulated with defaults. The struct corresponds to options nested under a key in a config file. I can create an instance of an anonymous struct with a field whose name refers to that key and value is a pointer to my original struct. I can then decode into the anonymous struct instance, and only fields present in the config file data will be updated, leaving the default fields intact.
The text was updated successfully, but these errors were encountered: