s/gofmt/goimports/

goimports is a superset of gofmt.  It does everything gofmt does, and
also organizes package imports.
pull/321/head
Eugene Kim 6 years ago
parent dd214dbd88
commit 0755123ca3
  1. 4
      CONTRIBUTING.md
  2. 16
      scripts/travis_checker.sh

@ -3,7 +3,7 @@
## Coding Guidelines
* In general, we follow [effective_go](https://golang.org/doc/effective_go.html)
* Code must adhere to the official [Go formatting guidelines](https://golang.org/doc/effective_go.html#formatting) (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
* Code must adhere to the official [Go formatting guidelines](https://golang.org/doc/effective_go.html#formatting) (i.e. uses [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports)).
* Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
## Pull Request (PR)
@ -13,7 +13,7 @@ This [github document](https://help.github.com/articles/creating-a-pull-request/
## PR requirement
To pursue engineering excellence, we have insisted on the highest stardard on the quality of each PR.
* For each PR, please run [golint](https://github.com/golang/lint), [gofmt](https://golang.org/cmd/gofmt/), to fix the basic issues/warnings.
* For each PR, please run [golint](https://github.com/golang/lint), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), to fix the basic issues/warnings.
* Make sure you understand [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/).
* Add a [Test] section in every PR detailing on your test process and results. If the test log is too long, please include a link to [gist](https://gist.github.com/) and add the link to the PR.

@ -12,7 +12,7 @@ print_file() {
echo "--- END ${2} ---"
}
unset -v ok tmpdir go_files go_dirs gofmt_output golint_output
unset -v ok tmpdir go_files go_dirs goimports_output golint_output
ok=true
tmpdir=
trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT
@ -56,16 +56,16 @@ else
ok=false
fi
echo "Running gofmt..."
gofmt_output="${tmpdir}/gofmt_output.txt"
xargs gofmt -d -e < "${go_files}" > "${gofmt_output}" 2>&1
if [ -s "${gofmt_output}" ]
echo "Running goimports..."
goimports_output="${tmpdir}/goimports_output.txt"
xargs goimports -d -e < "${go_files}" > "${goimports_output}" 2>&1
if [ -s "${goimports_output}" ]
then
echo "gofmt FAILED!"
print_file "${gofmt_output}" "gofmt"
echo "goimports FAILED!"
print_file "${goimports_output}" "goimports"
ok=false
else
echo "gofmt passed."
echo "goimports passed."
fi
if ! ${ok}

Loading…
Cancel
Save