-
Notifications
You must be signed in to change notification settings - Fork 212
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
Feature/255 keep fields ordered marshal struct #266
Feature/255 keep fields ordered marshal struct #266
Conversation
Codecov Report
@@ Coverage Diff @@
## master #266 +/- ##
==========================================
+ Coverage 90.72% 91.97% +1.25%
==========================================
Files 9 9
Lines 1789 1845 +56
==========================================
+ Hits 1623 1697 +74
+ Misses 120 103 -17
+ Partials 46 45 -1
Continue to review full report at Codecov.
|
Thank you so much for tackling that issue! I know it will make a lot of people happy. Overall the code looks good. I think However, I don't think introducing a var buf bytes.Buffer
err := toml.NewEncoder(&buf).Order(toml.OrderPreserve).Encode(v) A bit more verbose, but reuses the existing structure and allows for more flexibility, while keeping the API as small as possible. Definitely open to suggestions though! Thank you again. |
I implemented you suggestions. |
Looking great! Thank you! |
Here is a fix for #255
Tracking the order of members as they are marshaled so they can be written in order of the structure. Default behavior stays the same.
New func MarshalOrdered() allows a marshalOrder to be passed in. Current options are OrderAlphabetical (default) and OrderPreserve