go/format: Modified AST is formatted weirdly #49846
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I implemented a small refactoring tool that modifies the AST of a Go source file and writes the modified AST back to the file using
go/format
. The problem is that the formatting of the modified part looks off, i.e.format.Node
seems to randomly add indentation and linebreaks. This playground demonstrates the issue: https://go.dev/play/p/je4wZaGRZjq.What did you expect to see?
In the playground linked above I expected this to be the output of
format.Node
:What did you see instead?
This is what was rendered instead:
The text was updated successfully, but these errors were encountered: