Closed julienduchesne closed 1 year ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
I also looked into replicating the std.format function into go code but it seems like a monumental task, there are so many edge cases.
It is not actually that hard, https://github.com/CertainLach/jrsonnet/blob/master/crates/jrsonnet-evaluator/src/stdlib/format.rs
If going for the go-native string formatting instead, then something should be done against T
and the p
specifiers at least, since they wouldn't be pure, and will break the abstraction.
If there is a need to add another templating util, why not golang's text/template
instead?
It is familiar to devops too, and there won't be two templating functions that behave similarly, but not in quite the same way
I've identified that the main bottleneck in most of our jsonnet is actually string formatting It's one of the few things which haven't been ported from C-jsonnet
Here's a benchmark from the file I'm adding here and the equivalent jsonnet format:
goFormat:
Jsonnet:
I also looked into replicating the
std.format
function into go code but it seems like a monumental task, there are so many edge cases. So now, there are tons of differences between the C-style formatting and Go-style formatting so it's not a replacement but, could we have both? Go-style formatting is pretty common in the same places where jsonnet is used so it wouldn't be so out-of-place