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

Turn pkl Regex type into go regexp.Regexp type #44

Open
VincentSchmid opened this issue Apr 6, 2024 · 1 comment
Open

Turn pkl Regex type into go regexp.Regexp type #44

VincentSchmid opened this issue Apr 6, 2024 · 1 comment

Comments

@VincentSchmid
Copy link

It would be nice to have the Regex type convert to the regexp.Regexp type. Currently, I use a string and have to turn the string into regex within go before using it.

@bioball
Copy link
Contributor

bioball commented Apr 7, 2024

Pkl's regexes follow Java syntax. They don't map 1:1 to Go regex, which is why they don't get turned into Go's regexp.Regexp.

The pkl#Regex struct exists for compatibility sake, but it's not really meant to represent config data.

I'd actually suggest that you represent regexes as strings in Pkl if you mean to pass it into Go. You can add a @SourceCode annotation to get language injection in pkl-intellij:

@SourceCode { language = "RegExp" }
myRegex: String

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

2 participants