-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Default values (again!!) #1003
Comments
This would be so nice |
I want this feature too. |
I believe this fork has been created by k8s maintainers and would can serve for now: kubernetes-sigs/yaml#76 |
The reason is: it's already possible without struct tags. |
You, my good sir, are amazing. This is not what I wanted, but it's almost as good. If I ever meet you in person, you will drink as much beer as you want without ever having to touch your wallet. |
For anyone curious you can absolutely just define the structs as well and then it even works with structs (ie giving them a name instead of doing that anonymous struct definition) |
the hack only covers one use case of this feature supplying pre initialized values is impossible if there is unknown number of the container (such as when the struct [which contain fields with default values] are needed to be placed in a slice) https://go.dev/play/p/lopx3dR5QyP reproduce: make the |
Hallo,
I know this has been mentioned plenty of times (#462, #165 (comment) and so on) and that you can implement
UnmarshalYAML
to set your own defaults.Buuuuuut if you have multiple types of configs, and in each of them just a single field needs a default, implementing
UnmarshalYAML
in each of them makes your code quite bloated. It really seems complexity that could be hidden in the library itself.Is something like
in the roadmap? Or is there some deeper reason (I mean in the code) for this missing feature so it will never be implemented?
The text was updated successfully, but these errors were encountered: