In Travis CI, I want to check that my Go files are formatted properly via gofmt
and goimports
. During my CI builds, I only care about formatting issues in my own code, not in third-party repos.
Unfortunately, running a simple gofmt -l .
in the root of my project does not work because I'm using Godep, which checks in all of my external dependencies at ./Godep/_workspace
. While running go fmt ./...
ignores underscore-prefixed subdirectories, the plain gofmt .
does not. Neither gofmt
nor goimports
take the ./...
arg:
➜ goimports -l ./...
stat ./...: no such file or directory
Since I can use go list ./...
to get a list of all subpackages in my project (exluding vendored imports in an underscore-prefixed directory), I'm using the following to run gofmt
and goimports
on each of my own Go files (including _test.go
files):