3 ms·
Go AST was never really designed for re-writing of the source. Comments are stored by their byte offset instead of attached to nodes, so re-arranging nodes brea
by davelondon 5y ago
Go AST was never really designed for re-writing of the source. Comments are stored by their byte offset instead of attached to nodes, so re-arranging nodes breaks the output...
Check out my dst (decorated syntax tree) library: it allows you to manipulate Go source without breaking the comments and line-feeds:
https://github.com/dave/dst https://github.com/dave/dst