google / go-jsonnet

Apache License 2.0
1.63k stars 235 forks source link

feat: implement std.match as standard function #715

Open rohitjangid opened 1 year ago

rohitjangid commented 1 year ago

Implement std.match in standard library

cpp-jsonnet PR: https://github.com/google/jsonnet/pull/1100

coveralls commented 1 year ago

Coverage Status

coverage: 68.588% (+0.02%) from 68.568% when pulling 85282211ee714c8e71740006fd181b3101fb9b9c on rohitjangid:feat/stringmatch into fed90cd9cd733a87f9fb27cfb32a3e08a7695603 on google:master.

sparkprime commented 1 year ago

I was hoping to merge https://github.com/google/jsonnet/pull/1039 this release, but I don't think we have a go-jsonnet equivalent yet (@sbarzowski is that right?) Apparently the stdlib regexes in Go are similar enough that we can consider them compatible, in which case maybe all you have to do is make sure the API has the same function name / param name as the existing PR?

rohitjangid commented 1 year ago

If that is the case, I could create a separate PR with equivalent implementation of all the api in go. Let me know if I should go ahead with that considering cpp PR is yet to be merged.

rohitjangid commented 1 year ago

I didn't found any documentation for https://github.com/google/jsonnet/pull/1039 Is that part of any other PR?

sbarzowski commented 1 year ago

Very cool that this is happening!

Yeah, both this and https://github.com/google/jsonnet/pull/1039 are RE2 based, so I'd just use go standard library here. There are minor differences, but full regexp compatibility beyond simple cases cannot be guaranteed anyway – they are not specified precisely enough.

I didn't found any documentation for https://github.com/google/jsonnet/pull/1039

it doesn't have docs (yet), but you can see the summary in the PR description. If we could have the functions as described there, it would be great.

sparkprime commented 1 year ago

I think this is going to make a lot of users very happy