Fix printf formatting
This commit is contained in:
+3
-3
@@ -69,13 +69,13 @@ func Example_comprehensiveExample() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ func (f *matchFilterFn) call(node interface{}, ctx *queryContext) {
|
||||
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:
|
||||
|
||||
+6
-8
@@ -6,13 +6,11 @@ import (
|
||||
"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 @@ func (p *Position) String() string {
|
||||
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
|
||||
|
||||
@@ -138,7 +138,6 @@ func (p *queryParser) parseMatchExpr() queryParserStateFn {
|
||||
return nil // allow EOF at this stage
|
||||
}
|
||||
return p.parseError(tok, "expected match expression")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *queryParser) parseBracketExpr() queryParserStateFn {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ func TestTomlQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user