Skip to content

Commit

Permalink
Fix Offset method
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevsaddam committed Apr 5, 2019
1 parent 849a7b7 commit 352ba8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion go.mod

This file was deleted.

4 changes: 2 additions & 2 deletions jsonq.go
Expand Up @@ -165,11 +165,11 @@ func (j *JSONQ) Offset(offset int) *JSONQ {
// offset skips the records from result
func (j *JSONQ) offset() *JSONQ {
if list, ok := j.jsonContent.([]interface{}); ok {
if j.offsetRecords <= 0 {
if j.offsetRecords < 0 {
j.addError(fmt.Errorf("%d is invalid offset", j.offsetRecords))
return j
}
if len(list) > j.offsetRecords {
if len(list) >= j.offsetRecords {
j.jsonContent = list[j.offsetRecords:]
} else {
j.jsonContent = make([]interface{}, 0)
Expand Down

0 comments on commit 352ba8e

Please sign in to comment.