Open AuroraV opened 1 year ago
For https://github.com/wader/fq i inject context and some other things to functions, so something like this https://go.dev/play/p/fTC2swFweSO another way i think is to have struct with context etc and then have methods on it that you use with gojq.
But note that this only works if you run only one query or the context stays the same.
For https://github.com/wader/fq i inject context and some other things to functions, so something like this https://go.dev/play/p/fTC2swFweSO another way i think is to have struct with context etc and then have methods on it that you use with gojq.
But note that this only works if you run only one query or the context stays the same.
Thank you very much for your reply! I'm happy to discover the treasure of the fq
.
Regarding your second suggestion, it may not be feasible in my use case as the context is not globally unique, so this approach may not work.I hope it can be flexibly transformed at runtime, like RunWithContext
.
Thanks! ok guess it depends a bit on use case, for fq it seem the performance impact is not that bad to just re-compile and use new wrapper functions for each query
opcallctx
, WithFunction
+ new code through WithCtxFunction
I noticed that your func(any, []any) any function does not support the context.Context parameter. I was wondering if it would be possible to update the function signature to support the context.Context parameter. This would greatly enhance the usability of your code and make it more compatible with other libraries.
https://github.com/itchyny/gojq/issues/218