Add exmaple of direct get in README
diff --git a/README.md b/README.md index 02872ba..756e6d8 100644 --- a/README.md +++ b/README.md
@@ -31,11 +31,17 @@ 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