-
Notifications
You must be signed in to change notification settings - Fork 158
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
No pointer support #183
Comments
Hi @jxsl13. Will see if koanf can detect this and avoid it internally. |
I do define it as string pointer in the config (RootConfig) struct to indicate that it's optional. |
this might be my bad :). Guess this should be able to check both so I should probably use Get and check if it's a string pointer or a string. Initially I do load the default values from the struct pointer passed to the RegisterFlags function, so by default it assumes that this is a string pointer. (line 88 in koanf.go) |
Well, in general there is no pointer support. This is more of an enhencement requirement than a bug label, I guess. |
I wonder if this can be implemented with custom mapstructure hook function where for example time.Time is parsed as well. |
#262 Perhaps this newly merged fork has support for this? I can see that a bunch of pending PRs from the old repo have been merged on the fork. |
Closing this as I am not in a position to consider adding this functionality to the underlying lib. |
Hi,
I'm trying to integrate cobra and koanf in a way that I can provide flags, env variables or an optional .env config file path
in such a way that there is a hierarchy between those three input variants.
I'm trying to have a struct and struct tags which map to (dot)env variables as well as to flag names.
Pointer types in the struct are supposed to be somewhat optional but they seem to create some weird crash that I cannot exactly grasp.
I have created a minimal example of the problem and a launch.json for vs code: https://github.com/jxsl13/koanf-test
Starting this program instantly crashes.
Maybe my approach with pointer values is incorrect and there might be a better approach.
The text was updated successfully, but these errors were encountered: