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 ## Coding Guidelines
* In general, we follow [effective_go](https://golang.org/doc/effective_go.html) * 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. * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
## Pull Request (PR) ## Pull Request (PR)
@ -13,7 +13,7 @@ This [github document](https://help.github.com/articles/creating-a-pull-request/
## PR requirement ## PR requirement
To pursue engineering excellence, we have insisted on the highest stardard on the quality of each PR. 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/). * 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. * 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} ---" 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 ok=true
tmpdir= tmpdir=
trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT
@ -56,16 +56,16 @@ else
ok=false ok=false
fi fi
echo "Running gofmt..." echo "Running goimports..."
gofmt_output="${tmpdir}/gofmt_output.txt" goimports_output="${tmpdir}/goimports_output.txt"
xargs gofmt -d -e < "${go_files}" > "${gofmt_output}" 2>&1 xargs goimports -d -e < "${go_files}" > "${goimports_output}" 2>&1
if [ -s "${gofmt_output}" ] if [ -s "${goimports_output}" ]
then then
echo "gofmt FAILED!" echo "goimports FAILED!"
print_file "${gofmt_output}" "gofmt" print_file "${goimports_output}" "goimports"
ok=false ok=false
else else
echo "gofmt passed." echo "goimports passed."
fi fi
if ! ${ok} if ! ${ok}

Loading…
Cancel
Save