From bbe700c33e56c0adcddbde286064c6a3c9d282f5 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 6 Feb 2023 08:24:36 +0100 Subject: [PATCH] Apply formatting (go fmt) --- evaluable.go | 31 ++++++++++++++++--------------- gval.go | 13 +++++++------ gval_test.go | 2 +- language.go | 2 +- parse.go | 4 ++-- parser.go | 4 ++-- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/evaluable.go b/evaluable.go index dedcc3b..849f7c8 100644 --- a/evaluable.go +++ b/evaluable.go @@ -19,7 +19,7 @@ type Selector interface { // Evaluable evaluates given parameter type Evaluable func(c context.Context, parameter interface{}) (interface{}, error) -//EvalInt evaluates given parameter to an int +// EvalInt evaluates given parameter to an int func (e Evaluable) EvalInt(c context.Context, parameter interface{}) (int, error) { v, err := e(c, parameter) if err != nil { @@ -33,7 +33,7 @@ func (e Evaluable) EvalInt(c context.Context, parameter interface{}) (int, error return int(f), nil } -//EvalFloat64 evaluates given parameter to a float64 +// EvalFloat64 evaluates given parameter to a float64 func (e Evaluable) EvalFloat64(c context.Context, parameter interface{}) (float64, error) { v, err := e(c, parameter) if err != nil { @@ -47,7 +47,7 @@ func (e Evaluable) EvalFloat64(c context.Context, parameter interface{}) (float6 return f, nil } -//EvalBool evaluates given parameter to a bool +// EvalBool evaluates given parameter to a bool func (e Evaluable) EvalBool(c context.Context, parameter interface{}) (bool, error) { v, err := e(c, parameter) if err != nil { @@ -61,7 +61,7 @@ func (e Evaluable) EvalBool(c context.Context, parameter interface{}) (bool, err return b, nil } -//EvalString evaluates given parameter to a string +// EvalString evaluates given parameter to a string func (e Evaluable) EvalString(c context.Context, parameter interface{}) (string, error) { o, err := e(c, parameter) if err != nil { @@ -70,7 +70,7 @@ func (e Evaluable) EvalString(c context.Context, parameter interface{}) (string, return fmt.Sprintf("%v", o), nil } -//Const Evaluable represents given constant +// Const Evaluable represents given constant func (*Parser) Const(value interface{}) Evaluable { return constant(value) } @@ -82,15 +82,16 @@ func constant(value interface{}) Evaluable { } } -//Var Evaluable represents value at given path. -//It supports with default language VariableSelector: -// map[interface{}]interface{}, -// map[string]interface{} and -// []interface{} and via reflect -// struct fields, -// struct methods, -// slices and -// map with int or string key. +// Var Evaluable represents value at given path. +// It supports with default language VariableSelector: +// +// map[interface{}]interface{}, +// map[string]interface{} and +// []interface{} and via reflect +// struct fields, +// struct methods, +// slices and +// map with int or string key. func (p *Parser) Var(path ...Evaluable) Evaluable { if p.selector == nil { return variable(path) @@ -276,7 +277,7 @@ func (*Parser) callEvaluable(fullname string, fun Evaluable, args ...Evaluable) } } -//IsConst returns if the Evaluable is a Parser.Const() value +// IsConst returns if the Evaluable is a Parser.Const() value func (e Evaluable) IsConst() bool { pc := reflect.ValueOf(constant(nil)).Pointer() pe := reflect.ValueOf(e).Pointer() diff --git a/gval.go b/gval.go index affa02c..b0a039c 100644 --- a/gval.go +++ b/gval.go @@ -16,12 +16,12 @@ import ( "github.com/shopspring/decimal" ) -//Evaluate given parameter with given expression in gval full language +// Evaluate given parameter with given expression in gval full language func Evaluate(expression string, parameter interface{}, opts ...Language) (interface{}, error) { return EvaluateWithContext(context.Background(), expression, parameter, opts...) } -//Evaluate given parameter with given expression in gval full language using a context +// Evaluate given parameter with given expression in gval full language using a context func EvaluateWithContext(c context.Context, expression string, parameter interface{}, opts ...Language) (interface{}, error) { l := full if len(opts) > 0 { @@ -31,9 +31,10 @@ func EvaluateWithContext(c context.Context, expression string, parameter interfa } // Full is the union of Arithmetic, Bitmask, Text, PropositionalLogic, and Json -// Operator in: a in b is true iff value a is an element of array b -// Operator ??: a ?? b returns a if a is not false or nil, otherwise n -// Operator ?: a ? b : c returns b if bool a is true, otherwise b +// +// Operator in: a in b is true iff value a is an element of array b +// Operator ??: a ?? b returns a if a is not false or nil, otherwise n +// Operator ?: a ? b : c returns b if bool a is true, otherwise b // // Function Date: Date(a) parses string a. a must match RFC3339, ISO8601, ruby date, or unix date func Full(extensions ...Language) Language { @@ -106,7 +107,7 @@ func Ident() Language { } // Base contains equal (==) and not equal (!=), perentheses and general support for variables, constants and functions -// It contains true, false, (floating point) number, string ("" or ``) and char ('') constants +// It contains true, false, (floating point) number, string ("" or “) and char (”) constants func Base() Language { return base } diff --git a/gval_test.go b/gval_test.go index a9be139..6fe5145 100644 --- a/gval_test.go +++ b/gval_test.go @@ -48,7 +48,7 @@ func testEvaluate(tests []evaluationTest, t *testing.T) { } } -//dummyParameter used to test "parameter calls". +// dummyParameter used to test "parameter calls". type dummyParameter struct { String string Int int diff --git a/language.go b/language.go index b6844a6..26e3cf8 100644 --- a/language.go +++ b/language.go @@ -171,7 +171,7 @@ func PrefixMetaPrefix(r rune, ext func(context.Context, *Parser) (call string, a return l } -//PrefixOperator returns a Language with given prefix +// PrefixOperator returns a Language with given prefix func PrefixOperator(name string, e Evaluable) Language { l := newLanguage() l.prefixes[l.makePrefixKey(name)] = func(c context.Context, p *Parser) (Evaluable, error) { diff --git a/parse.go b/parse.go index 789b62e..142ca53 100644 --- a/parse.go +++ b/parse.go @@ -10,7 +10,7 @@ import ( "github.com/shopspring/decimal" ) -//ParseExpression scans an expression into an Evaluable. +// ParseExpression scans an expression into an Evaluable. func (p *Parser) ParseExpression(c context.Context) (eval Evaluable, err error) { stack := stageStack{} for { @@ -31,7 +31,7 @@ func (p *Parser) ParseExpression(c context.Context) (eval Evaluable, err error) } } -//ParseNextExpression scans the expression ignoring following operators +// ParseNextExpression scans the expression ignoring following operators func (p *Parser) ParseNextExpression(c context.Context) (eval Evaluable, err error) { scan := p.Scan() ex, ok := p.prefixes[scan] diff --git a/parser.go b/parser.go index 9b8d389..1590af3 100644 --- a/parser.go +++ b/parser.go @@ -8,7 +8,7 @@ import ( "unicode" ) -//Parser parses expressions in a Language into an Evaluable +// Parser parses expressions in a Language into an Evaluable type Parser struct { scanner scanner.Scanner Language @@ -113,7 +113,7 @@ func (p *Parser) TokenText() string { return p.scanner.TokenText() } -//Expected returns an error signaling an unexpected Scan() result +// Expected returns an error signaling an unexpected Scan() result func (p *Parser) Expected(unit string, expected ...rune) error { return unexpectedRune{unit, expected, p.lastScan} }