You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/Jacalz/eval

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Jacalz/eval

v1.0.1-0.20230117135256-70762a43ec9b
Source
Go
Version published
Created
Source

eval

A minimalistic math parser for Go. It implements the shunting-yard-algorithm and allows to parse math from strings.

Work in progress

The current implementation requires spaces between each math token and does not support trigionometric functions yet.

Example

The library can be used as illustrated below:

package main

import (
	"fmt"

	"github.com/jacalz/eval"
)

func main() {
	input := "( 6 - 2 * ( 6 / 3 ) ) ^ 3"
	
	result, err := eval.Evaluate(input)
	if err != nil {
		panic(err)
	}

	fmt.Println(result)
}

A more elaborate example can be found in the example folder.

FAQs

Package last updated on 17 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts