Go library for document's content modification
import (
"os"
"github.com/asciimoth/inplace"
"github.com/asciimoth/inplace/toml"
)
func main() {
root, _ := os.OpenRoot(".")
_ = inplace.PatchFile(
toml.New,
root,
"Cargo.toml",
[]inplace.Patch{
{
KP: []string{"package", "name"},
Value: "NEWNAME",
},
{
KP: []string{"package", "version"},
Value: "3.1.4",
},
},
)
}Note that this library created for specific cases with simple scalar values manipulation.
If you need more complex ast manipulation check this libs:
If you need to just marshal/unmarshal formats to go data structures check this: