Skip to content
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

Add *Tree.SetPositionPath #426

Merged
merged 1 commit into from
Aug 1, 2020
Merged

Add *Tree.SetPositionPath #426

merged 1 commit into from
Aug 1, 2020

Conversation

sclevine
Copy link
Contributor

I needed to add this function to support generating arbitrary, ordered TOML from other data serialization formats in yj.

*Tree.SetPath does not set Positions correctly when other *Trees are used as values. This makes the Encoder behave strangely when OrderPreserve is set: https://play.golang.org/p/Lns42AVkEcT

Additionally, *Tree.SetPath doesn't appear to be sufficient to generate arbitrary TOML when *Tree values are not used. For example, there doesn't appear to be a way to append tables to a list.

Adding this method seems to be all that's necessary to allow arbitrary, ordered TOML to be generated, which seems useful.

Signed-off-by: Stephen Levine <stephen.levine@gmail.com>
@codecov
Copy link

codecov bot commented Jul 26, 2020

Codecov Report

Merging #426 into master will decrease coverage by 1.01%.
The diff coverage is 36.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #426      +/-   ##
==========================================
- Coverage   94.93%   93.91%   -1.02%     
==========================================
  Files          10       10              
  Lines        2387     2433      +46     
==========================================
+ Hits         2266     2285      +19     
- Misses         80      107      +27     
  Partials       41       41              
Impacted Files Coverage Δ
toml.go 76.27% <6.25%> (-7.38%) ⬇️
marshal.go 96.28% <100.00%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34de94e...ed50a27. Read the comment docs.

@pelletier pelletier added the feature Issue asking for a new feature in go-toml. label Aug 1, 2020
@pelletier
Copy link
Owner

Thanks for the patch! Impressive we had the getters for so long without the setter 😅

@pelletier pelletier merged commit 661484a into pelletier:master Aug 1, 2020
@sclevine
Copy link
Contributor Author

sclevine commented Aug 1, 2020

Thanks for the quick merge! 🎉

jabrown85 added a commit to jabrown85/yj that referenced this pull request Jun 11, 2021
Trying to unblock buildpacks/lifecycle#628. The fork's commit was merged into the mainline module [here](pelletier/go-toml#426).

Signed-off-by: Jesse Brown <jabrown85@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue asking for a new feature in go-toml.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants