Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

tq: Preserve YAML comments by reattaching them per path

Open
#106 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go, yaml
Domain
cli

Research direction

Start with how the tq command decodes YAML input through any and how the Node model holds it, since the proposal keeps comments outside that model. The issue depends on an OrderedMap that is not yet in place, so check that dependency first. Done means a tq -e ... --inplace edit keeps head, line and foot comments and scalar styles on paths that still exist, and the known limits are documented.

Written by the indexing model from the issue text.

Description

enhancement

Problem

YAML is decoded through any, so comments, anchors and scalar styles are lost. Editing a config file with tq -e ... --inplace rewrites every line, which rules out the main use case yq covers.

Proposed solution

Keep this out of the core Node model and handle it in tq:

  1. Also decode the input into yaml.Node and collect path → {HeadComment, LineComment, FootComment, Style}.
  2. Query/edit the tree as usual.
  3. When encoding the result to yaml.Node, copy comments and scalar styles back onto nodes whose path still exists.

Depends on key order preservation (OrderedMap) to be useful.

Known limits, to be documented: comments can shift to a neighbour when array elements are inserted/removed; anchors/aliases stay expanded (out of scope for 1.0).

Dominant language
Go
Stars
7
Forks
2
Avg merge
11h 12m
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mojatter/tree

All issues in mojatter/tree

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.