Closed gcstang closed 2 years ago
The decision to remove toml.Tree
and the surrounding API was intentional. See the v2 README.
In v2 you'll need to unmarshal into a map[string]interface{}
.
The decision to remove
toml.Tree
and the surrounding API was intentional. See the v2 README.In v2 you'll need to unmarshal into a
map[string]interface{}
.
So I have to create what used to be in v1 now if I want to upgrade?... seems an odd decision I only need to upgrade because something was added to v2 instead of in v1 where it was broken, specifically the ability to add a comment on an array #595
Could this be fixed in 1.x instead?
@pelletier has said that v1 is deprecated now that v2 is released.
@pelletier has said that v1 is deprecated now that v2 is released.
Doesn't really answer my question as now there is a large gap in my reason for using this project. @pelletier please provide a solution even if it's a one off as you fixed the issue I outlined but then broke functionality so I can't even migrate as you originally asked.
The old toml. LoadFile
+ toml.ToMap
can be accomplished with ioutil.ReadFile
+ toml.Unmarshal
. For example:
data, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
var props map[string]interface{}
err = toml.Unmarshal(data, &props)
if err != nil {
panic(err)
}
So I have to create what used to be in v1 now if I want to upgrade?... seems an odd decision
The removal of the FromFile
and ToMap
API was on purpose. It simplifies the maintenance of go-toml, and lets the application decide how to handle I/O, as it has more context than go-toml to do this.
If you encounter specific bugs with the code above please open dedicated issues to track them.
The old
toml. LoadFile
+toml.ToMap
can be accomplished withioutil.ReadFile
+toml.Unmarshal
. For example:data, err := ioutil.ReadFile(path) if err != nil { panic(err) } var props map[string]interface{} err = toml.Unmarshal(data, &props) if err != nil { panic(err) }
So I have to create what used to be in v1 now if I want to upgrade?... seems an odd decision
The removal of the
FromFile
andToMap
API was on purpose. It simplifies the maintenance of go-toml, and lets the application decide how to handle I/O, as it has more context than go-toml to do this.If you encounter specific bugs with the code above please open dedicated issues to track them.
Thank you but comment on toml array type doesn't display but non-array still works, so far other things seem to work.
Describe the bug API missing when migrating from v1.9.4 to v2.0.0
To Reproduce Steps to reproduce the behavior. Including TOML files. Use in code
tree, err := toml.LoadFile(path)
if err != nil {
return err
}
props := tree.ToMap()
Expected behavior API should be available to pass a map[string]interface{} as in v1
Versions
Additional context Add any other context about the problem here that you think may help to diagnose.