Closed
Description
When map is of type map[string]string (for example its source is the env) the get function returns an empty string instead of nil when the key doesn't exist
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
func main() {
emptyMap := make(map[string]string)
env := map[string]interface{}{
"empty_map": emptyMap,
}
code := `get(empty_map, "non_existing_key")`
program, err := expr.Compile(code, expr.Env(env))
if err != nil {
panic(err)
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Printf("%T, %s", output, output)
}