-
Notifications
You must be signed in to change notification settings - Fork 212
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
comment in struct #184
Labels
feature
Issue asking for a new feature in go-toml.
Comments
with PR, it's that: type TypeC struct {
my string
}
type TypeB struct {
AttrA string `toml:"user" comment:"A comment on AttrA"`
AttrB string `toml:"password" comment:"A comment on AttrB"`
AttrC string `toml:"noComment"`
My []TypeC `comment:"a comment on My"`
}
type TypeA struct {
TypeB TypeB `toml:"postgres" comment:"it's a comment on type"`
} marshall -> # postgres it's a comment on type
[postgres]
noComment = "cvalue"
# A comment on AttrB
password = "bvalue"
# A comment on AttrA
user = "avalue"
# a comment on My
[[postgres.My]]
# a comment on My
[[postgres.My]] |
type TypeC struct {
My string `comment:"a comment on my on typeC"`
}
type TypeB struct {
AttrA string `toml:"user" comment:"A comment on AttrA"`
AttrB string `toml:"password" comment:"A comment on AttrB with a\n break line"`
AttrC string `toml:"noComment"`
AttrD string `toml:"isCommented" commented:"true"`
My []TypeC `comment:"a comment on My"`
}
type TypeA struct {
TypeB TypeB `toml:"postgres" comment:"it's a comment on type"`
}
ta := []TypeC{{My: "Foo"}, {My: "Baar"}}
config := TypeA{TypeB{AttrA: "avalue", AttrB: "bvalue", AttrC: "cvalue", AttrD: "dvalue", My: ta}}
result, err := Marshal(config) will returns: # it's a comment on type
[postgres]
# isCommented = "dvalue"
noComment = "cvalue"
# A comment on AttrB with a
# break line
password = "bvalue"
# A comment on AttrA
user = "avalue"
# a comment on My
[[postgres.My]]
# a comment on my on typeC
My = "Foo"
[[postgres.My]]
# a comment on my on typeC
My = "Baar" |
Love it! Will review the PR shortly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Do you plan to do something like this:
for
Or is there a way to add comment in output ?
Thks
The text was updated successfully, but these errors were encountered: