- How to parse and (re)write
*.go
source files
- Use
parser.ParseFile(...)
to build a*ast.File
from a file or from source as[]byte
- Use
printer.Fprint(...)
to write a*ast.File
to a Writer - core ast package handles comments poorly
TODO ...
- https://github.com/dave/dst
- https://eli.thegreenplace.net/2021/rewriting-go-source-code-with-ast-tooling/
- https://medium.com/justforfunc/understanding-go-programs-with-go-parser-c4e88a6edb87
- https://astexplorer.net/
- https://yuroyoro.github.io/goast-viewer/index.html
- https://abhinavg.net/posts/understanding-token-pos/