Improve doc for un/marshal functions (#189)

This commit is contained in:
Thomas Pelletier
2017-10-01 15:47:47 -07:00
committed by GitHub
parent 690dbc9ee7
commit 2009e44b6f
2 changed files with 18 additions and 2 deletions
+7 -2
View File
@@ -61,19 +61,24 @@ func ExampleMarshal() {
type Postgres struct {
User string `toml:"user"`
Password string `toml:"password"`
Database string `toml:"db" commented:"true" comment:"not used anymore"`
}
type Config struct {
Postgres Postgres `toml:"postgres"`
Postgres Postgres `toml:"postgres" comment:"Postgres configuration"`
}
config := Config{Postgres{User: "pelletier", Password: "mypassword"}}
config := Config{Postgres{User: "pelletier", Password: "mypassword", Database: "old_database"}}
b, err := toml.Marshal(config)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
// Output:
// # Postgres configuration
// [postgres]
//
// # not used anymore
// # db = "old_database"
// password = "mypassword"
// user = "pelletier"
}