Giter VIP home page Giter VIP logo

expr's Introduction

expr

Golang rule engine, support logical expression

Support type: int string float bool

Support operation: > < >= <= && || + - * /

Support two inner funnction: in_array(1, []int{1,2,3,4}), ver_compare(x, ">", "10.1.1") with no nested

I believe it satisfy most filter scenarios using rule engine for logical expression.

Finally, Welcome contribution or requirement.

How to use it

package main

import (
	expr "github.com/pjnr1/expr"
	log "github.com/s00500/env_logger"
)

func main() {
	expr := "1.0 * 2.0 > 1.5 + _test_"
	control := map[string]interface{}{"_test_": 1.5}
	engine, err := expr.NewEngine(expr)
	log.Must(err)
	
	result, err := engine.RunRule(control)
	log.Must(err)
	
	log.Infoln(result)
}

the ast parser using Golang go/ast and go/parser, rule can be update using engine.UpdateAst to avoid parse the rule each time. more demo please refer to the expr_test.go

Contributing

Pull requests, bug fixes and issue reports are welcome and appreciated.

Licence

MIT

expr's People

Contributors

lqiz avatar pjnr1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.