-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
pointer-embedded fields are not supported #240
Comments
Playing with this some more, it seems I am noticing that the issue is the I assume this is because the parser wouldn't have anywhere to "put" the data... I suppose I can workaround this by leaving out the pointer... Although I guess creating a struct there would be convenient too if it's possible. LMK, and in the worst case scenario I can create a docs patch for this if you'd like one. Cheers |
PS: For anyone following at home, I've updated my WIP branch which is here: https://github.com/purpleidea/mgmt/tree/feat/go-arg The interesting commit is here: purpleidea/mgmt@9527d0d |
Yeah, it's as you say - the library supports directly-embedded structs but not pointer-embedded structs. In order to support pointer-embedded structs, we would have to decide under what conditions to allocate and initialize the pointer. We might do that always no matter what, or only if an option is provided that should go in to the pointer-embedded struct, or perhaps whenever the pointer-embedded struct contains fields that the library recognizes as command line arguments. I'd be open to a PR that just always initializes pointer-embedded structs. |
I was doing some lovely refactoring and I was able to take my main tool's config struct, separate it out, decorate it with the
arg
struct tags, and then embed it both in my main struct and also in a new struct which also included some fields for sub commands.I then got the following error:
The struct looks approximately like this:
In the lib package:
It seems we don't support the embedded struct? Either this is a "feature we need to add" or there's some gotcha I don't know about. In either case, I'd appreciate your feedback, and would appreciate a patch even more!
The text was updated successfully, but these errors were encountered: