Add exmaple of direct get in README

This commit is contained in:
Thomas Pelletier
2013-06-30 13:31:48 +02:00
parent 523e11f0d3
commit f2a1344e12
+10 -4
View File
@@ -31,11 +31,17 @@ import (
config, err := toml.LoadFile("config.toml")
if err != nil {
fmt.Println("Error ", err.Error())
} else {
// retrieve data directly
user := config.Get("postgres.user").(string)
password := config.Get("postgres.password").(string)
// or using an intermediate object
configTree := config.Get("postgres").(*toml.TomlTree)
user = configTree.Get("user").(string)
password = configTree.Get("password").(string)
fmt.Println("User is ", user, ". Password is ", password)
}
configTree := config.Get("postgres").(*toml.TomlTree)
user := configTree.Get("user").(string)
password := configTree.Get("password").(string)
fmt.Println("User is ", user, ". Password is ", password)
```
## Documentation