Commit 7517e09
authored
respect output file path on gofmt failure (#2356)
When `imports.Process` rejected the generated source, `Generate()`
discarded the code and stuffed a line-numbered dump of it into the
returned error. The CLI then printed that error to stderr and never
wrote the requested `-o` (or config `output:`) file, so users saw a
huge stderr spew with no output file produced.
Return the raw pre-format code from `Generate()` alongside the error,
and have the CLI write it to the configured destination before
exiting. The error message itself is now a single line referencing
the failing source line; users can open the written file to inspect
the broken code directly. `addLineNumbers` is dropped — it was only
used by the removed in-error code dump.
Closes: #23401 parent 9643421 commit 7517e09
2 files changed
Lines changed: 23 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
324 | | - | |
325 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
326 | 340 | | |
327 | 341 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 342 | + | |
| 343 | + | |
338 | 344 | | |
339 | 345 | | |
340 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
521 | 520 | | |
522 | 521 | | |
523 | 522 | | |
524 | | - | |
525 | 523 | | |
526 | 524 | | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
| 525 | + | |
| 526 | + | |
542 | 527 | | |
543 | | - | |
544 | | - | |
| 528 | + | |
545 | 529 | | |
546 | | - | |
547 | | - | |
| 530 | + | |
548 | 531 | | |
549 | 532 | | |
550 | 533 | | |
| |||
0 commit comments