Fix printf formatting
diff --git a/doc_test.go b/doc_test.go index 7c0e677..6945241 100644 --- a/doc_test.go +++ b/doc_test.go
@@ -69,13 +69,13 @@ fmt.Println("User is ", user, ". Password is ", password) // show where elements are in the file - fmt.Println("User position: %v", configTree.GetPosition("user")) - fmt.Println("Password position: %v", configTree.GetPosition("password")) + fmt.Printf("User position: %v\n", configTree.GetPosition("user")) + fmt.Printf("Password position: %v\n", configTree.GetPosition("password")) // use a query to gather elements without walking the tree results, _ := config.Query("$..[user,password]") for ii, item := range results.Values() { - fmt.Println("Query result %d: %v", ii, item) + fmt.Printf("Query result %d: %v\n", ii, item) } } }
diff --git a/match.go b/match.go index 423a869..085d294 100644 --- a/match.go +++ b/match.go
@@ -202,7 +202,7 @@ fn, ok := (*ctx.filters)[f.Name] if !ok { panic(fmt.Sprintf("%s: query context does not have filter '%s'", - f.Pos, f.Name)) + f.Pos.String(), f.Name)) } switch castNode := tomlValueCheck(node, ctx).(type) { case *TomlTree:
diff --git a/position.go b/position.go index 1f26245..0ac907c 100644 --- a/position.go +++ b/position.go
@@ -6,13 +6,11 @@ "fmt" ) -/* - Position of a document element within a TOML document. - - Line and Col are both 1-indexed positions for the element's line number and - column number, respectively. Values of zero or less will cause Invalid(), - to return true. -*/ +// Position of a document element within a TOML document. +// +// Line and Col are both 1-indexed positions for the element's line number and +// column number, respectively. Values of zero or less will cause Invalid(), +// to return true. type Position struct { Line int // line within the document Col int // column within the line @@ -24,7 +22,7 @@ return fmt.Sprintf("(%d, %d)", p.Line, p.Col) } -// Returns whether or not the position is valid (i.e. with negative or +// Invalid returns whether or not the position is valid (i.e. with negative or // null values) func (p *Position) Invalid() bool { return p.Line <= 0 || p.Col <= 0
diff --git a/queryparser.go b/queryparser.go index 8c0de8d..e7caa1e 100644 --- a/queryparser.go +++ b/queryparser.go
@@ -138,7 +138,6 @@ return nil // allow EOF at this stage } return p.parseError(tok, "expected match expression") - return nil } func (p *queryParser) parseBracketExpr() queryParserStateFn {
diff --git a/toml_test.go b/toml_test.go index c89b973..e7f8f16 100644 --- a/toml_test.go +++ b/toml_test.go
@@ -65,7 +65,7 @@ } if tt, ok := values[0].(*TomlTree); !ok { - t.Errorf("Expected type of TomlTree: %T Tv", values[0], values[0]) + t.Errorf("Expected type of TomlTree: %T", values[0]) } else if tt.Get("a") != int64(1) { t.Errorf("Expected 'a' with a value 1: %v", tt.Get("a")) } else if tt.Get("b") != int64(2) {