Show HN: gq – like jq or zq, but you use Go

Show HN: gq – like jq or zq, but you use Go

This is another fancy item!!

jq but using go instead.

go install

Or download the binaries here

Pipe some input into gq and pass in a block of go code as the argument. The variable j is set to the passed in JSON and printed at the end of the function, so manipulate it (e.g below) in order to change the output. The gq library is inlined in the program, and described in detail in the API reference above.


$ echo ‘{“weird”: [“nested”, {“complex”: “structure”}]}’ | gq ‘j.G(“weird”).I(1).G(“complex”)’


$ echo ‘[“list”, “of”, “mostly”, “uninterseting”, “good/strings”, “good/welp”]’ | gq ‘j.Filter(func(n *Node) bool { return strings.Contains(n.String(), “good/”) })’


$ echo ‘[1, 2, 3, 4]’ | gq ‘j.Map(func(n *Node) *Node {n.val=n.Int() + 50 / 2; return n})’

jq is hard to use. There are alternatives like fq and zq, but they still make you learn a new programming language. Im tired of learning new programming languages.

gq is not optimized for speed, flexibility or beauty. gq is optimized for minimal learning/quick usage. gq understands that you don’t use it constantly, you use it once a month and then forget about it. So when you come back to it, gq will be easy to relearn. Just use the builtin library just like you would any other go project and you’re done. No unfamiliar syntax or operations, or surprising limits. Thats it.

Speaking of surprising limits, gq runs your code in the yaegi go interpreter. This means that it runs quickly for small inputs/programs (the alternative was go run, which is… not quite as quick). However, it also means its not the fastest *q out there, and further it means that you might run into quirks with yaegi interpretation limitations. Seems to work pretty well so far though.

Yea, well, I built it last night, so, yea it kinda sucks. But please file issues! Or submit PRs! Maybe this will turn into something useful? At least maybe it will inspire some conversation.

I think it needs a lot of refinement still, in short.

Read More
Share this on to discuss with people on this topicSign up on now if you’re not registered yet.

Related Articles

What’s recent in Emacs 28.1?

By Mickey Petersen It’s that time again: there’s a new major version of Emacs and, with it, a treasure trove of new features and changes.Notable features include the formal inclusion of native compilation, a technique that will greatly speed up your Emacs experience.A critical issue surrounding the use of ligatures also fixed; without it, you…

Windows 11 Guide

A guide on setting up your Windows 11 Desktop with all the essential Applications, Tools, and Games to make your experience with Windows 11 great! Note: You can easily convert this markdown file to a PDF in VSCode using this handy extension Markdown PDF. Getting Started Windows 11 Desktop Bypass Windows 11’s TPM, CPU and…

x86 Is an Octal Machine

# source: From: (Mark Hopkins) Newsgroups: alt.lang.asm Subject: A Summary of the 80486 Opcodes and Instructions (1) The 80×86 is an Octal Machine This is a follow-up and revision of an article posted in alt.lang.asm on 7-5-92 concerning the 80×86 instruction encoding. The only proper way to understand 80×86 coding is to realize that…


Your email address will not be published. Required fields are marked *