patterngoCritical
Go fmt on a whole source tree
Viewed 0 times
treesourcefmtwhole
Problem
I have a project currently organized something like this:
~/code/go
/bin
/pkg
/src
/proj/main.go
/some_package/package.go
/some_other_package/some_other_package.go
Now if I want to use the
Is there some way to tell the fmt command to run on the whole source tree?
~/code/go
/bin
/pkg
/src
/proj/main.go
/some_package/package.go
/some_other_package/some_other_package.go
Now if I want to use the
go fmt tool on my whole project it seems that the only way is to do it separately for each directory in my projects source tree:go fmt proj
go fmt proj/package
go fmt proj/some_other_packageIs there some way to tell the fmt command to run on the whole source tree?
Solution
You can use three dots (
This wildcard also works with other go commands like
...) as a wildcard. So for example, the following command will format all github.com packages:go fmt github.com/...This wildcard also works with other go commands like
go list, go get and so. There is no need to remember such an ugly find command.Code Snippets
go fmt github.com/...Context
Stack Overflow Q#13319165, score: 151
Revisions (0)
No revisions yet.