-
Notifications
You must be signed in to change notification settings - Fork 42
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
Support for string constexpr evaluation #444
Comments
If this were implemented, I would expect it to work similar to // ExprValue describes a compile-time computable value of a matched expr.
type ExprValue struct{}
// Int returns compile-time computable int value of the expression.
// If value can't be computed, condition will fail.
func (ExprValue) Int() int { return intResult }
// Int returns compile-time computable int value of the expression.
// If value can't be computed, condition will fail.
func (ExprValue) String() string { return stringResult } I think your example would be a little trickier in that case, since it would have to be something more like matched, err := regexp.Match(m["msg"].Value.String())
m.Match["$msg"].Where(err != nil && matched) I'm not sure the DSL is really capable of handling something like that, without a lot of special casing... I was hoping for something similar to this for m.Match["$msg"].Report("error").Suggest(strings.ToTitle(m["msg"].Value.String())) Once again the use of arbitrary |
The DSL does not support the arbitrary code. |
As discussed in #443, I would like the ability to do something like the following in a
Where
:Right now, it is possible to approximate this using
Text.Matches
, e.g.:However, this has the disadvantage of requiring you to handle the different kinds of string literals (or, more likely, only handle the most common case as above).
Thank you!
The text was updated successfully, but these errors were encountered: