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 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_package
Is there some way to tell the fmt command to run on the whole source tree?
You can use three dots (...
) 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.