Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

tq: Keep the file when -U produces no result

Chiusa
#154 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

Read cmd/tq/main.go, especially evaluateInputFile, and inspect the existing TestRunInplace cases. Run the in-place tests to see how queries with no result behave. Decide whether to preserve the file and fail or write the empty result, then add a test row that confirms the chosen behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

tq -U replaces the target with an empty file and exits 0 when the query produces no result, e.g. tq -U .typo config.json on {"a": 1} leaves config.json at 0 bytes. A typo in the query silently wipes the file.

This is not new: on main before #153 the empty temp output was copied over the truncated target the same way, and the temp + rename write-back from #153 keeps it.

To decide:

  • Keep the file and fail, e.g. failed to write config.json: no result, when nothing was written. This needs a written-bytes check on the in-place temp file in evaluateInputFile (cmd/tq/main.go).
  • Or keep writing the empty result and document it, since an empty result is what the query asked for.

Add a TestRunInplace row for a query with no result either way.

Lingua principale
Go
Stelle
7
Fork
2
Merge medio
12h 9m
PR unite (30g)
33

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mojatter/tree

Tutte le issue di mojatter/tree

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.