Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var trivialXml = []byte(`<root>a<foo>b</foo>c<bar>d</bar>e<bar>f</bar>g</root>`)
func (s *BasicSuite) TestRootText(c *C) {
node, err := xmlpath.Parse(bytes.NewBuffer(trivialXml))
c.Assert(err, IsNil)
path := xmlpath.MustCompile("/")
path, _ := xmlpath.MustCompile("/")
result, ok := path.String(node)
c.Assert(ok, Equals, true)
c.Assert(result, Equals, "abcdefg")
Expand Down
6 changes: 3 additions & 3 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ func (step *pathStep) match(node *Node) bool {

// MustCompile returns the compiled path, and panics if
// there are any errors.
func MustCompile(path string) *Path {
func MustCompile(path string) (*Path, error) {
e, err := Compile(path)
if err != nil {
panic(err)
return nil, err
}
return e
return e, nil
}

// Compile returns the compiled path.
Expand Down