LineFeed in string results in error on Evaluate
Opened this issue · 0 comments
mjurczik commented
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:)