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

eval

package
v3.1.61 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT, 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.

Source Files

  • eval.go

Jump to

Keyboard shortcuts

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