Re:Show HN: gq – like jq or zq, but you use Go
by errnil on Wednesday April 27, 2022 @01:05PM
(#31182676)
No doubt this tool is lacking. However I will say that for me the most important quality in my `jq`-like is not conciseness. My main frustration is that I always forget the small details of how `jq`'s language works and spend 10 minutes googling. E.g doing operations within arrays of objects, using select, and so on. Maybe I'm just dumb, but I'm fond of tools that accommodate my dumbness!
Re:Show HN: gq – like jq or zq, but you use Go
by nh23423fefe on Wednesday April 27, 2022 @01:02PM
(#31182632)
| gq 'j.Filter(func(n *Node) bool { return strings.Contains(n.String(), "good/") })'
| jq 'map(select(contains("good/")))'
Re:Show HN: gq – like jq or zq, but you use Go
by throwaway894345 on Wednesday April 27, 2022 @03:30PM
(#31184675)
I like jq, but the parent is right that it's hard to wrap one's head around the way jq thinks about things and how that model maps to its grammar. Even in this example, I couldn't tell you why `map()` wraps everything else, and I always get tripped up on when to use `|` or how to go back and forth between a list and a stream. I don't think the answer is `gq`, but I certainly understand why people try out other languages.
Re:Show HN: gq – like jq or zq, but you use Go
by nh23423fefe on Wednesday April 27, 2022 @04:33PM
(#31185399)
every filter operates on its input. in this case the input was an array.
every map implementation ive seen has type function(a,b) -> list(a) -> list(b)
select(contains("good/")) is a function from string -> string|void
so map plus a voidable function equals a filter
| just means connect 2 filters
if you have a stream you turn it into a array with the array constructor []
if you have an array you turn it into a stream with the producer operator .[]
the api is super orthogonal and well designed. but you do have to understand the model
Re:Show HN: gq – like jq or zq, but you use Go
by throwaway894345 on Wednesday April 27, 2022 @06:44PM
(#31186760)
Right, I already believe it all makes sense when you understand the model, but the model isn't super obvious and I often find myself Googling things for reference because I don't use it very often; however, I do use regular programming languages and I can reason about those more easily (although while I like Go, I would be more inclined to used a Python- or JS-like language for something like this).
Re:Show HN: gq – like jq or zq, but you use Go
by mccanne on Wednesday April 27, 2022 @01:04PM
(#31182665)
zq good/ -
Re:Show HN: gq – like jq or zq, but you use Go
by spacemanmatt on Wednesday April 27, 2022 @02:46PM
(#31184124)
i can get the same jq from multiple package installers that will ensure it is in my execution path. this covers windows and linux, and likely osx if i needed it.
Re:Show HN: gq – like jq or zq, but you use Go
by sleepybrett on Wednesday April 27, 2022 @01:44PM
(#31183290)
Also this seems to mean my pipeline needs to know how to compile go if i want to transform some json .. boo hiss
Learning the jq syntax will have a much better payoff in the long run.