From 16398bac157da96aa88f98a2df640c7f32af1da2 Mon Sep 17 00:00:00 2001 From: KANEKO Tatsuya Date: Mon, 25 Sep 2017 03:42:18 +0900 Subject: [PATCH] Fix example code in README (#187) --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22da41a8..2681690d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import "github.com/pelletier/go-toml" Read a TOML document: ```go -config, _ := toml.LoadString(` +config, _ := toml.Load(` [postgres] user = "pelletier" password = "mypassword"`) @@ -42,7 +42,7 @@ user := config.Get("postgres.user").(string) // or using an intermediate object postgresConfig := config.Get("postgres").(*toml.Tree) -password = postgresConfig.Get("password").(string) +password := postgresConfig.Get("password").(string) ``` Or use Unmarshal: @@ -62,7 +62,7 @@ user = "pelletier" password = "mypassword"`) config := Config{} -Unmarshal(doc, &config) +toml.Unmarshal(doc, &config) fmt.Println("user=", config.Postgres.User) ``` @@ -70,7 +70,8 @@ Or use a query: ```go // use a query to gather elements without walking the tree -results, _ := config.Query("$..[user,password]") +q, _ := query.Compile("$..[user,password]") +results := q.Execute(config) for ii, item := range results.Values() { fmt.Println("Query result %d: %v", ii, item) }