Help us shape the future of Go! Take the 2026 Go Developer Survey

gostr

command module
v0.0.0-...-63f1938 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2017 License: MIT Imports: 1 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL