Running the "go fmt" command recursively

Hello Everyone,

Does anyone know how to run “go fmt” recursively on many files?

I use webstorm. If anyone also knows how to configure webstorm to run “go fmt” upon a file being closed, I would love to know this, too.

Thank you!

To go tool works on packages*, so you can run it on the current package and any subdirectories like this

go fmt ./...

*nitpickers note, some go commands also work with files, which is confusing and always leads to misunderstandings.

5 Likes

Thank you so much! I really appreciate the speedy response.

Thank you so much, Dave Cheney. I finally got back on my Mac and ran it. It worked great. I really appreciate the help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.