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
Is your feature request related to a problem? Please describe.
I would like to use the same toml struct to marshal a struct with concrete values to a file and to generate example configuration file.
In the example configuration file, all lines should be commented.
Currently it's only possible to change the commented option per field tag.
I can only comment or uncomment them but not have both variants when marshalling the same struct.
Describe the solution you'd like
Add an encoder option to change the default commented setting for fields.
This way it would be possible to omit the commented tag and set the default to true when marshaling the struct as an example config.
Describe alternatives you've considered
Instead of having an option to set the default, have an option to enforce/overwrite the commented tag for all fields in the encoder
Add the the tag commented = true to all my fields, when I'm not marshalling the struct into an example config, call e.SetTagCommented("nonexistingtag)` to ignore the tag setting and have everything uncommented
The text was updated successfully, but these errors were encountered:
fho
changed the title
Allow changing the default commented value
Allow changing the default value of the commented tag
Jul 9, 2020
Closing this issue, as go-toml v2.0.0 has been released, and commented tags are not supported anymore. As go-toml v1 will not be receiving any updates, please look into upgrading to the new version. If you believe this is a mistake please reach out!
@pelletier when upgrading to go-toml v2, how can one still replicate the commented tag feature, such that some toml field is commented out after marshalling.
It's not possible at the moment. One option would be to perform some post-processing on the output if you know how fields would look like. Or you help out on the marshaling of the new AST struct (#822).
Is your feature request related to a problem? Please describe.
I would like to use the same toml struct to marshal a struct with concrete values to a file and to generate example configuration file.
In the example configuration file, all lines should be commented.
Currently it's only possible to change the
commented
option per field tag.I can only comment or uncomment them but not have both variants when marshalling the same struct.
Describe the solution you'd like
Add an encoder option to change the default
commented
setting for fields.This way it would be possible to omit the
commented
tag and set the default totrue
when marshaling the struct as an example config.Describe alternatives you've considered
commented
tag for all fields in the encodercommented = true
to all my fields, when I'm not marshalling the struct into an example config, calle.SetTagCommented("nonexistingtag
)` to ignore the tag setting and have everything uncommentedThe text was updated successfully, but these errors were encountered: