Better Programming

Advice for programmers.

Follow publication

Member-only story

How yq 4.x is Built

Stefanie Lai
Better Programming
Published in
6 min readAug 1, 2023
image by Reid Naaykens from Unsplash

As one of the best tools for processing YAML files, yq is very “active” in cloud developers' toolboxes. However, the usage, syntax, and test of yq operators still confuse many users, especially when handling complex YAML files, where writing yq expressions is extremely hard. Of course, we can grasp yq by memorizing most functions and usage methods of its main operators, just as I did in Cheatsheet for the “yq” Tool, but it is far from enough for processing complex YAML with combined operators.

From a programmer’s perspective, I believe the source code can help you use and debug yq.

Source Code Structure

yq is essentially a command-line tool implemented with Go, so the file and directory are similar to most Go projects.

  • yq.go is the entry of yq, that is, the common main.go, containing the main method.
  • The cmd directory is the entry of the yq command and subcommand and also where the definition of the parameters lie, whose code is implemented with the common Cobra package.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Write a response