Repository: diegoholiveira/jsonlogic (go)

Issue:
0 divided by any number returning denominator instead of 0
Here is the sample program to reproduce 

```
package main

import (
	"bytes"
	"fmt"
	"strings"
	"github.com/diegoholiveira/jsonlogic"
)

func main() {
	rule := `{"/":[0,10]}`
	logic := strings.NewReader(rule)
	data := strings.NewReader(`{}`)
	var result bytes.Buffer

	jsonlogic.Apply(logic, data, &result)

	fmt.Println(result.String())

}
```

Pull request:
Use the position of the number to identify the first number
Closes #28 

Patch:
diff --git a/jsonlogic.go b/jsonlogic.go
index 47bb10a..81e6f0c 100644
--- a/jsonlogic.go
+++ b/jsonlogic.go
@@ -279,14 +279,14 @@ func mult(values interface{}) interface{} {
 func div(values interface{}) interface{} {
 	var sum float64
 
-	for _, n := range values.([]interface{}) {
-		if sum == 0 {
+	for i, n := range values.([]interface{}) {
+		if i == 0 {
 			sum = toNumber(n)
 
 			continue
 		}
 
-		sum /= toNumber(n)
+		sum = sum / toNumber(n)
 	}
 
 	return sum


Test patch:
diff --git a/jsonlogic_test.go b/jsonlogic_test.go
index 5ebbda4..1d4a644 100644
--- a/jsonlogic_test.go
+++ b/jsonlogic_test.go
@@ -468,3 +468,13 @@ func TestMissingOperators(t *testing.T) {
 
 	assert.EqualError(t, err, "The operator \"sum\" is not supported")
 }
+
+func TestZeroDivision(t *testing.T) {
+	logic := strings.NewReader(`{"/":[0,10]}`)
+	data := strings.NewReader(`{}`)
+	var result bytes.Buffer
+
+	Apply(logic, data, &result) // nolint:errcheck
+
+	assert.JSONEq(t, `0`, result.String())
+}