diff --git a/doc_test.go b/doc_test.go index 3b8171b..d64414c 100644 --- a/doc_test.go +++ b/doc_test.go @@ -16,13 +16,14 @@ func Example_tree() { fmt.Println("Error ", err.Error()) } else { // retrieve data directly - user := config.Get("postgres.user").(string) - password := config.Get("postgres.password").(string) + directUser := config.Get("postgres.user").(string) + directPassword := config.Get("postgres.password").(string) + fmt.Println("User is", directUser, " and password is", directPassword) // or using an intermediate object configTree := config.Get("postgres").(*toml.Tree) - user = configTree.Get("user").(string) - password = configTree.Get("password").(string) + user := configTree.Get("user").(string) + password := configTree.Get("password").(string) fmt.Println("User is", user, " and password is", password) // show where elements are in the file diff --git a/keysparsing_test.go b/keysparsing_test.go index 5a7530b..3858259 100644 --- a/keysparsing_test.go +++ b/keysparsing_test.go @@ -24,7 +24,7 @@ func testResult(t *testing.T, key string, expected []string) { func testError(t *testing.T, key string, expectedError string) { res, err := parseKey(key) if err == nil { - t.Fatalf("Expected error, but succesfully parsed key %s", res) + t.Fatalf("Expected error, but successfully parsed key %s", res) } if fmt.Sprintf("%s", err) != expectedError { t.Fatalf("Expected error \"%s\", but got \"%s\".", expectedError, err) diff --git a/marshal.go b/marshal.go index 95c77bc..d35ac85 100644 --- a/marshal.go +++ b/marshal.go @@ -546,8 +546,8 @@ func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, if !found && opts.defaultValue != "" { mvalf := mval.Field(i) - var val interface{} = nil - var err error = nil + var val interface{} + var err error switch mvalf.Kind() { case reflect.Bool: val, err = strconv.ParseBool(opts.defaultValue) diff --git a/toml.go b/toml.go index a5f2bfc..358a9be 100644 --- a/toml.go +++ b/toml.go @@ -275,7 +275,7 @@ func (t *Tree) Delete(key string) error { return t.DeletePath(keys) } -// Delete removes a key from the tree. +// DeletePath removes a key from the tree. // Keys is an array of path elements (e.g. {"a","b","c"}). func (t *Tree) DeletePath(keys []string) error { keyLen := len(keys) diff --git a/tomltree_write.go b/tomltree_write.go index 6acd4f7..198d5ac 100644 --- a/tomltree_write.go +++ b/tomltree_write.go @@ -259,7 +259,7 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64, a } func (t *Tree) writeToOrdered(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool, ord marshalOrder) (int64, error) { - orderedVals := make([]sortNode, 0) + var orderedVals []sortNode switch ord { case OrderPreserve: