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

make tree struct properties and tomlValue public #466

Closed
vincentserpoul opened this issue Jan 28, 2021 · 4 comments
Closed

make tree struct properties and tomlValue public #466

vincentserpoul opened this issue Jan 28, 2021 · 4 comments

Comments

@vincentserpoul
Copy link
Contributor

I'm trying to enable toml for https://github.com/mozilla/sops with this lib, but it's quite difficult not to be able to work directly with the comment/values/tomlValue in order to parse the toml.Tree into sops.TreeBranches.
I tried to work with the map ( tree.ToMap() ) but it makes things quite complicated for no reason (on top of losing the comments and positions).

Is there any reason why these types/properties were kept private?
Any possibility of making these public? or creating a new public struct type and a new function allowing the access to these infos?

@pelletier
Copy link
Owner

No good reason for those types to be private -- it was a design error years ago when I was learning Go. As future work, I'd like to break backward compatibility and create a new interface for manipulating TOML documents that does not suffer from all the shortcomings the current one has. In the meantime, I am open to making those types available if we can find a backward-compatible way to do it!

@vincentserpoul
Copy link
Contributor Author

I think as a quick fix, we can probably create new types with public props and methods to create from the existing closed types.
Adding to that, a new method on Tree to transform to the new fully public type.

If I'm not wrong, that should work and only add a functionality without breaking the existing impl.

What do you think?

@pelletier
Copy link
Owner

Sounds reasonable. Looks like a method on Tree to convert wouldn't even be necessary, as you could just cast it to the public type?

@vincentserpoul
Copy link
Contributor Author

i think so, I realized as I was doing it that the even more simple type aliasing make things easy.
You can indeed directly cast it to the alias for tje tree as well, so no need for additional functions (as far as I can see).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants