Open joshlf opened 9 years ago
Actually, here's an idea: struct field tags define comments. Something like:
type Person struct {
Name string `toml:"name,the peron's name"`
Age string `toml:"age,the person's age"`
}
(the idea is that the comma separates the key name and the comment; the tag toml:",comment"
would be valid)
Hugу +1 for this. @BurntSushi wanna push in?
+1
Would love to have this feature. +1 from me.
This is a great idea. It would be nice to separate the comment into an additional tag. For example we could use something like desc (description) or com (comment)
type Person struct {
Name string `toml:"name" desc:"the person's name"`
Age string `toml:"age" desc:"the person's age"`
}
@BurntSushi Is it still considered as feature request? I have reworked https://github.com/BurntSushi/toml/pull/97 a bit to support comment tag https://github.com/BurntSushi/toml/pull/235
Given that TOML supports comments, it would be nice if there were some way to emit TOML which included comments. My initial inclination was to implement the TextMarshaler interface, but it seems that doesn't work for key/value pairs (so you can't use it to omit a custom line of TOML).
My suggestion is that something be added which could be used to support this. I'm not sure what it would look like (a more flexible encoding mechanism? specific support for comments?), but it would be great to have.