Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neonxp/gomathexecutor
Package GoMathExecutor provides simple expression executor
https://github.com/neonxp/gomathexecutor
Last synced: about 1 month ago
JSON representation
Package GoMathExecutor provides simple expression executor
- Host: GitHub
- URL: https://github.com/neonxp/gomathexecutor
- Owner: neonxp
- License: mit
- Created: 2020-02-13T19:56:05.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-13T20:15:56.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T12:51:13.750Z (7 months ago)
- Language: Go
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoMathExecutor [![GoDoc](https://godoc.org/github.com/neonxp/GoMathExecutor?status.svg)](https://godoc.org/github.com/neonxp/GoMathExecutor) [![Build Status](https://travis-ci.org/neonxp/GoMathExecutor.svg?branch=master)](https://travis-ci.org/neonxp/GoMathExecutor) [![codecov](https://codecov.io/gh/neonxp/GoMathExecutor/branch/master/graph/badge.svg)](https://codecov.io/gh/neonxp/GoMathExecutor)
Package GoMathExecutor provides simple expression executor.
## Installation
`go get github.com/neonxp/GoMathExecutor`
## Usage
```
calc := executor.NewCalc()
calc.AddOperators(executor.MathOperators) // Loads default MathOperators (see: defaults.go)
calc.Prepare("2+2*2") // Prepare expression
calc.Execute(nil) // == 6, nil
calc.Prepare("x * (y+z)") // Prepare another expression with variables
calc.Execute(map[string]float64{
"x": 3,
"y": 2,
"z": 1,
}) // == 9, nil
```