Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineFeed in string results in error on Evaluate #99

Open
mjurczik opened this issue Aug 29, 2023 · 0 comments
Open

LineFeed in string results in error on Evaluate #99

mjurczik opened this issue Aug 29, 2023 · 0 comments

Comments

@mjurczik
Copy link

mjurczik commented Aug 29, 2023

Hello,

if the expression contains a line feed character instead of the string representation parsing of expression fails.
I don't know if this is intentional to only allow single line expressions and if it is my responsibility to replace all new line runes with their string representation.

Example code:

package main

import (
	"fmt"
	"github.com/PaesslerAG/gval"
)

func main() {
	expressionWithLF := `"hello
world"`
expressionWithNewLine := `"hello\nworld"`
eval(expressionWithLF)
eval(expressionWithNewLine)

}

func eval(expression string) {
	r, err := gval.Evaluate(expression, nil)
	fmt.Println(r, err)
	fmt.Println("---")
}

Output

<nil> parsing error: "hello
world"	:1:1 - 2:1 could not parse string: invalid syntax
---
hello
world <nil>
---

Take care:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant