eval

package
v0.0.0-...-d2a29bb Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExprError

type ExprError struct {
	// contains filtered or unexported fields
}

func (ExprError) Error

func (err ExprError) Error() string

func (ExprError) Unwrap

func (err ExprError) Unwrap() error

type Num

type Num struct {
	Value any // int64 or float64, nil on error
}

func Expr

func Expr(tokens ...any) (Num, error)

Expr evaluates the given expression tokens and returns the result. It supports the following operators: +, -, *, /, and, or, not, ==, !=, >, >=, <, <=. Non-zero values are treated as true, zero values are treated as false. If no error occurs, the result is either an int64 or a float64. If all numbers are integer, the result is an int64, otherwise if there is any float number, the result is a float64.

Jump to

Keyboard shortcuts

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