Skip to content

pk-rawat/gostr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status wercker status

gostr

DESCRIPTION

Gostr is a evaluator for a mathematical and logical expressions that allows run-time binding of values to variables referenced in the formulas.

EXAMPLE

This is probably simplest to illustrate in code:

values := make(map[string]interface{})
values["a"] = 5
result := gostr.Evaluate("a * 2", values)
fmt.Println("Result:", result)
#=> Result: 10

result := gostr.Evaluate("a + 3 * 2", values)
fmt.Println("Result:", result)
#=> Result: 11

result := gostr.Evaluate("(a + 3) * 2", values)
fmt.Println("Result:", result)
#=> Result: 16

I have added some simple examples. Run example.go to check those.

BUILT-IN OPERATORS AND FUNCTIONS

Math: + - * /

Logic: < > <= >= <> != = AND OR

Functions: ISBLANK LENGTH NOT ROUND

Releases

No releases published

Packages

No packages published

Languages