Skip to content

Kite is an expression evaluator written in Go. It supports all format of expression variables such as strings, numbers, float and even versions.

License

Notifications You must be signed in to change notification settings

sahilpaudel/kite-go

Repository files navigation

Kite Go


Provides support for evaluating string expressions.

How to use it?


You need to have 3 arguments to evaluate your expression.

  • The string expression that defines the actual values and comparators against which the evaluation will happen platform=='android'&&version>='10.9.8'&&segment==89
  • The map of interface that defines the expression variables that you want to evaluate
     {
        "platform": "android",
        "version": "12.3.4",
        "segment": 98
     }
    
    • The final part is a list of Variable struct which defines the type of the variable in the expression.
      • variable1 := Variable{
           Name:  "appVersion",
           Type:  Version,
           Value: "10.9.7",
         }
        variable2 := Variable{
           Name:  "platform",
           Type:  String,
           Value: "android",
         }
        var variables []Variable
        
        variables = append(variables, variable1)
        variables = append(variables, variable2)
        

We will use all this to call the EvaluateExpression which returns a *bool and error

variable1 := Variable{
    Name:  "appVersion",
    Type:  Version,
    Value: "10.9.7",
}
variable2 := Variable{
    Name:  "platform",
    Type:  String,
    Value: "android",
}
variable3 := Variable{
    Name:  "segment",
    Type:  Number,
    Value: 98,
}

var variables []Variable

variables = append(variables, variable1)
variables = append(variables, variable2)
request := map[string]interface{}{
    "appVersion": "10.9.8",
}

result, err := EvaluateExpression("appVersion>='10.9.8'&&segment==98&&platform=='android'", request, variables)

About

Kite is an expression evaluator written in Go. It supports all format of expression variables such as strings, numbers, float and even versions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published