Skip to content

Commit

Permalink
rql: changing types to pointers (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Aug 1, 2019
1 parent f662c28 commit 405945f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rql.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@ func MustNewParser(c Config) *Parser {
// Parse parses the given buffer into a Param object. It returns an error
// if the JSON is invalid, or its values don't follow the schema of rql.
func (p *Parser) Parse(b []byte) (pr *Params, err error) {
q := new(Query)
q := &Query{}
if err := q.UnmarshalJSON(b); err != nil {
return nil, &ParseError{"decoding buffer to *Query: " + err.Error()}
}
return p.ParseQuery(*q)
return p.ParseQuery(q)
}

// ParseQuery parses the given struct into a Param object. It returns an error
// if one of the query values don't follow the schema of rql.
func (p *Parser) ParseQuery(q Query) (pr *Params, err error) {
func (p *Parser) ParseQuery(q *Query) (pr *Params, err error) {
defer func() {
if e := recover(); e != nil {
perr, ok := e.(ParseError)
perr, ok := e.(*ParseError)
if !ok {
panic(e)
}
Expand Down Expand Up @@ -469,15 +469,15 @@ func (p *Parser) op(op Op) string {
// expect panic if the condition is false.
func expect(cond bool, msg string, args ...interface{}) {
if !cond {
panic(ParseError{fmt.Sprintf(msg, args...)})
panic(&ParseError{fmt.Sprintf(msg, args...)})
}
}

// must panics if the error is not nil.
func must(err error, msg string, args ...interface{}) {
if err != nil {
args = append(args, err)
panic(ParseError{fmt.Sprintf(msg+": %s", args...)})
panic(&ParseError{fmt.Sprintf(msg+": %s", args...)})
}
}

Expand Down

0 comments on commit 405945f

Please sign in to comment.