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
Say I wanted to load a TOML file from a program, change a value, and write it back to disk.
The current configuration makes that difficult. Say I wanted to change the value in testdata/example.toml. I would call toml.Parse() and eventually get an ast.Value, but there's no way to modify that, and updating the Value would not update the ast.Table.Data. In addition, it doesn't seem like there's a way to convert an *ast.Table back into a []byte.
The text was updated successfully, but these errors were encountered:
You're right, there is no built-in support for modifying the AST. It would be interesting to know what your use case is.
You can do simple transformations by parsing into interface{}, modifying the result and finally writing it back out using Marshal. This is lossy because formatting and comments are lost. If the AST had support for modifications, how should comments/formatting be handled?
Use case is writing an Go program to manipulate values in a user's TOML
file, say to bump a version number, or change the value of a string. I
can't do that if it loses comments.
On Sun, Apr 16, 2017 at 8:42 AM, Felix Lange ***@***.***> wrote:
You're right, there is no built-in support for modifying the AST. It would
be interesting to know what your use case is.
You can do simple transformations by parsing into interface{}, modifying
the result and finally writing it back out using Marshal. This is lossy
because formatting and comments are lost. If the AST had support for
modifications, how should comments/formatting be handled?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#36 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAOSIy45ShT7iOy2Iai9AYNPU3hlFrosks5rwjbYgaJpZM4M-jKO>
.
Say I wanted to load a TOML file from a program, change a value, and write it back to disk.
The current configuration makes that difficult. Say I wanted to change the value in
testdata/example.toml
. I would calltoml.Parse()
and eventually get anast.Value
, but there's no way to modify that, and updating theValue
would not update the ast.Table.Data. In addition, it doesn't seem like there's a way to convert an*ast.Table
back into a[]byte
.The text was updated successfully, but these errors were encountered: