Hacker News new | past | comments | ask | show | jobs | submit login

As far as I understand go fmt works on the AST, if your reformatter doesn't work on the AST then you will eventually have problems.

Also go fmt doesn't ever change your code, thats what go fix is for.




> As far as I understand go fmt works on the AST, if your reformatter doesn't work on the AST then you will eventually have problems.

JsFmt also works on the AST. Working on the AST does not mean your rewrite rules can be bulletproof, let alone are.


From the readme:

> Javascript formatters exist but most (all?) work on just strings, not the AST. Using Esprima under the hood we have access to the full AST and can do useful things like intelligent find and replace as in gofmt.


gofmt -r applies rewrite rules, and -s also performs source transformations; both change the code.


gofmt without flags does not change your code. Yes, you can ask it to change your code if you want it to, but by default, it won't.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: